O'Reilly logo

Win32 Perl Programming: The Standard Extensions, Second Edition by Dave Roth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding Domain Controllers

I am always amazed how often I find code that assumes that a particular circumstance will be true. Someone will hardcode a script to refer to a primary domain controller (PDC), for example. It is possible for a primary domain controller to go down and a backup domain controller (BDC) to automatically step in and act as a temporary PDC, or an administrator can manually promote a BDC to take over the role of the PDC. (If this occurs, the PDC steps down and acts as a BDC.) Because of this, it is a bad idea to hardcode a PDC’s computer name into a script. You should instead resolve the name of the domain’s PDC using the GetDomainController() function:

 Win32::NetAdmin::GetDomainController($Server, $Domain, $Name); Win32::Lanman::NetGetDCName($Server, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required