简体   繁体   中英

Force PrincipalContext to connect to a specific server

Is there a way to force PrincipalContext to connect to a specific Domain Controller? I'm enumerating the list of locked accounts for my application, and I would like to be able to query multiple servers and return the list from all DCs.

Currently I get whichever DC my PrincipalContext happens to connect to, and my list is not always completely correct of accounts that are locked out.

I've done some digging, but don't see any way to make reference to which Domain Controller the call for PrincipalContext connects to.

Yes, you can connect to a specific domain controller.

new PrincipalContext(ContextType.Domain, name, container, username, password);

The name part of this principal context can be set to an IP address of a domain controller. I assume that you speak about different active directories otherwise you may have a problem how the domain controllers are distributing the information.

Also, make sure the container is the correct with OC=... and DC=... .

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM