Possible Duplicate:
How to know if my DirectoryEntry is really connected to my LDAP directory?
I am calling DirectoryEntry() with an invalid Domain on purpose to test how my C# application handles the case if a server goes down, etc. DirectoryEntry() does not throw an exception - it returns (seemingly normally) but when debugging, I cannot view the contents of directoryEntry - it times out on the variable expansion.
Its not until I perform an operation on the DirectorySearcher object that the program hangs for minutes before returning an exception "Server Is Not Operational". It appears setting the clientTimeout doesn't help either. Any suggestions?
TimeSpan timeout = new TimeSpan(0, 0, 0, 15, 0);
string domain = "asdf";
DirectoryEntry myDirectoryEntry = new DirectoryEntry("LDAP://" + domain);
DirectorySearcher mySearcher = new DirectorySearcher(myDirectoryEntry);
mySearcher.ClientTimeout = timeout;
mySearcher.Filter = "(&(objectCategory=person)(objectClass=user));
searcher.FindAll(); //this takes minutes with invalid domain!!!