Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Find nearest domain controller?

Reply
Thread Tools Display Modes

Find nearest domain controller?

 
 
Philip Colmer
Guest
Posts: n/a

 
      08-15-2008
I've got a multi-domain, multi-site infrastructure. I need to be able to
query the list of domain controllers for a given domain and figure out which
one is the nearest to me.

If it helps, it would be safe to assume that the code is being run on a PC
in a site that has a domain controller for the domain in question.

Can someone suggest how this can be done?

Thanks.

--Philip

 
Reply With Quote
 
 
 
 
Olaf Engelke [MVP]
Guest
Posts: n/a

 
      08-15-2008
Hi Philip,
Philip Colmer wrote:
> I've got a multi-domain, multi-site infrastructure. I need to be able
> to query the list of domain controllers for a given domain and figure
> out which one is the nearest to me.
>
> If it helps, it would be safe to assume that the code is being run on
> a PC in a site that has a domain controller for the domain in
> question.


if the Domain controller is in the same site as the PC, it is usually the
one, which is used as logonserver.
So with
echo %logonserver%
you should get the domain controller, which responded most quick to the
logon attempt.
Best greetings from Germany
Olaf

 
Reply With Quote
 
Philip Colmer
Guest
Posts: n/a

 
      08-16-2008
Thank you for the suggestion, Olaf, but I'm not looking for the domain
controller that I've logged on against. I need to find the nearest domain
controller for a specific domain - we have a multi-domain infrastructure that
spans multiple sites and we've got administrators in multiple sites working
on all of those domains, so my script needs to be able to connect to the
nearest DC for a specific domain in order to reduce replication impact on the
performance of the script.

Regards

Philip

"Olaf Engelke [MVP]" wrote:

> Hi Philip,
> Philip Colmer wrote:
> > I've got a multi-domain, multi-site infrastructure. I need to be able
> > to query the list of domain controllers for a given domain and figure
> > out which one is the nearest to me.
> >
> > If it helps, it would be safe to assume that the code is being run on
> > a PC in a site that has a domain controller for the domain in
> > question.

>
> if the Domain controller is in the same site as the PC, it is usually the
> one, which is used as logonserver.
> So with
> echo %logonserver%
> you should get the domain controller, which responded most quick to the
> logon attempt.
> Best greetings from Germany
> Olaf
>

 
Reply With Quote
 
Olaf Engelke [MVP]
Guest
Posts: n/a

 
      08-16-2008
Hi Philip.
Philip Colmer wrote:
> Thank you for the suggestion, Olaf, but I'm not looking for the domain
> controller that I've logged on against. I need to find the nearest
> domain controller for a specific domain - we have a multi-domain
> infrastructure that spans multiple sites and we've got administrators
> in multiple sites working on all of those domains, so my script needs
> to be able to connect to the nearest DC for a specific domain in
> order to reduce replication impact on the performance of the script.
>

so you are sitting in one domain and neet to find the for you "nearest"
domain controller for another domain from the PC you are just sitting on?
Or do you mean the local site admin needs to find his local domain
controller?
In last case I still would tend to the logon server as criteria.
Btw. - the best way to reduce network impact of scripts is in my eyes still
to execute them directly on an appropriate server via Remotedesktop.
The Remotedesktops mmc console is a great tool for that centralized access
and you do not need to run security sensitive stuff directly from your
desktop, giving any virus the same permission to access network ressources
as yourself.
Best greetings from Germany
Olaf

 
Reply With Quote
 
Philip Colmer
Guest
Posts: n/a

 
      08-17-2008


"Olaf Engelke [MVP]" wrote:

> Hi Philip.
> Philip Colmer wrote:
> > Thank you for the suggestion, Olaf, but I'm not looking for the domain
> > controller that I've logged on against. I need to find the nearest
> > domain controller for a specific domain - we have a multi-domain
> > infrastructure that spans multiple sites and we've got administrators
> > in multiple sites working on all of those domains, so my script needs
> > to be able to connect to the nearest DC for a specific domain in
> > order to reduce replication impact on the performance of the script.
> >

> so you are sitting in one domain and neet to find the for you "nearest"
> domain controller for another domain from the PC you are just sitting on?
> Or do you mean the local site admin needs to find his local domain
> controller?
> In last case I still would tend to the logon server as criteria.
> Btw. - the best way to reduce network impact of scripts is in my eyes still
> to execute them directly on an appropriate server via Remotedesktop.
> The Remotedesktops mmc console is a great tool for that centralized access
> and you do not need to run security sensitive stuff directly from your
> desktop, giving any virus the same permission to access network ressources
> as yourself.
> Best greetings from Germany
> Olaf


The problem I have is that I've been working on a script to create new user
accounts and it needs to be able to create accounts in multiple domains
during a single run session, mainly to be bullet-proof against administrators
who don't split their CSV files up into separate domains and run the script
on the best server as you suggest.

It seems as if this is probably a harder problem to code for than I
anticipated.

--Philip

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: 1 PC can't find domain controller JohnB Server Networking 13 12-03-2008 05:53 PM
Cannot find domain controller Yakob Active Directory 44 11-23-2007 03:08 AM
Re: Domain Controller cannot find itself Myweb Active Directory 1 07-07-2007 06:45 PM
WinNT 4 WS - cannot find domain controller to join AD domain FLEWIS Active Directory 0 04-02-2004 05:41 PM
Cannot Find Domain Controller Scott Virtual PC 6 12-03-2003 10:40 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59