WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Microsoft Client
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Determine if a Server is a PDC or BDC

Keywords:   primary domain controller PDC backup domain controller BDC 

Question:

Does anyone know of a way to determine a the status of an NT server programmatically, ie. read a registry value? In other words, how do you determine if the server is a Primary Domain Controller (PDC) or Backup Domain Controller (BDC), etc. ?

Answer:

Maybe look at:
wntServerType
wntServiceInf
in the Win32 Network Extender.

Here's where it's located in the registry, so you can use RegQueryValue to retrieve it from HKLM\System\CurrentControlSet\Control\ProductOptions\ProductType, with:

   RegQueryValue(@regmachine, "CurrentControlSet\Control\ProductOptions[ProductType]")        
ProductType will be one of three values: or it might appear as:
   WINNT = WorkStation
   LANMANNT = Enterprise Server
   SERVERNT = Server

A real quick way to determine the PDC is to do a "net time /domain:domainname". This always sets the time from the PDC, giving a message to that extent. You could pipe the output into a file and then parse it for "\\".

I mention this because it is not always the case that the registry security allows lookups, specially if someone has run C2config against the registry.

We use this in our login and it works for both 4.0 and 3.51. Don't do a case sensitive compare as they are not always in caps.


Article ID:   W13528
Filename:   Determine if a Server is an NT PDC.txt
File Created: 2000:02:08:12:21:44
Last Updated: 2000:02:08:12:21:44