Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get the currently active domain controller

2 views
Skip to first unread message

Magnusb

unread,
Dec 18, 2009, 11:39:44 AM12/18/09
to
I need to get the name of an active DC in a domain (might be a different
than the current domain I am using). I need to get the DC which is
active and up not just which DC are defined in the Domain. basiclaly
the same dc dicovery that windows will do.

I have tried using something like this and it seems to work, but not
sure if it is the best (and fastest) way to do it:

DirectoryContext ctx = new DirectoryContext(DirectoryContextType.Domain,
"domain", "user", "password");
Domain domain = Domain.GetDomain(ctx);
DomainController dc = domain.FindDomainController();

dc.Name contains name of dc.

Does FindDomainController working like how Windows will locate a dc?
Should I use LocatorOption.ForceRediscovery?

Joe Kaplan

unread,
Dec 18, 2009, 12:27:20 PM12/18/09
to
It works using DC locator which means you can also specify a specific site
if you want. You should not need to call ForceRediscovery in most cases but
it *should* guarantee that you get a DC that is up. If locator found a DC in
that domain and cached it previously and then the DC went down, you might
get an error unless you force rediscovery. Might be best perf to only force
if you get an error.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
"Magnusb" <mag...@sbbs.se> wrote in message
news:MPG.2595cea08...@msnews.microsoft.com...

jokij

unread,
Jan 9, 2010, 4:50:01 PM1/9/10
to

just joking
"Magnusb" wrote:

> .
>

yth

unread,
Jan 9, 2010, 4:51:02 PM1/9/10
to
just another joke

"Joe Kaplan" wrote:

> .
>

nana

unread,
Jan 9, 2010, 4:52:01 PM1/9/10
to
nah
0 new messages