c# - Get the connected server of a PrincipalContext for global catalog -


i have method createcontextforglobalcatalog returns principalserver connects global catalog:

principalcontext = new principalcontext(contexttype.domain,                                         "forest.name:3268",                                          "dc=forest,dc=name",                                          contextoptions.negotiate,                                          username, password); 

note: reduced version of method, name , container parameters.

with context i'm looping on objects database information global catalog in activedirectory:

using (principalcontext principalcontext = createcontextforglobalcatalog()) {     foreach (adaccount adaccount in accounts){        log.debug("connected server: " + principalcontext.connectedserver);      // information ad here ...     } } 

the log.debug line logs connected server principalcontext. have test setup containing virtual machines.

my problem: when disconnect connected server (disable network adapter) don't exception , connected new server log messages still shows original connected server albeit server not available anymore.

is there way somehow refresh connected server property or information somewhere else?

unfortunately, never updated after initiation, workaround can recheck every iteration if still connected or not


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -