slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, Is there a way to return the domain controller of a particular machine? We are using Active Directory on a Windows 2000 server. Thanks for any thoughts. Steve

Replies are listed 'Best First'.
Re: Get Domain Controller
by NetWallah (Canon) on Aug 25, 2004 at 16:47 UTC
    My interpretation, from the way the question is phrased, is that you are looking for the DC that logged you in.

    That info is in the environment variable "LOGONSERVER". in perl, you can get the info by querying

    $ENV{LOGONSERVER}
    In case you are looking for more generic info on how to find all DC's for a domain, here is my code for that:

        Earth first! (We'll rob the other planets later)

Re: Get Domain Controller
by ikegami (Patriarch) on Aug 25, 2004 at 16:46 UTC

    I have an ENV var called LOGONSERVER which appears to be the name of the domain controller.

    >print -le "print $ENV{'LOGONSERVER'}" \\WEIDC21