views:

9

answers:

0

When using a DirectoryEntry to initialize a DirectorySearcher object, I've been just using the simple LDAP string of "LDAP://dc=mydomain,dc=com". The problem with this method is that on Windows XP, it will only use the LogonServer (the domain controller that was used when logging in to Windows). I've encountered cases where that domain controller would go down for maintenance causing my queries to fail. Reading Microsoft's documentation on how DCs are located, it says once a DC is found it will be cached and doesn't say anything about updating the cache so maybe this is just the way XP works?

So I started going down the route of doing a DNS lookup to find all the valid DCs for my domain then loop through each one checking to see if port 389 was open and if it could handle a simple bind request (basically make sure the DC is properly responding). This seems like a lot of extra work that should be built into .NET or Windows itself.

Does anybody have any suggestions on what the proper way to search ActiveDirectory without going through this extra work? I have noticed that on Windows 7, the simple LDAP string works properly: it will automatically connect to a valid domain controller even if the LogonServer (or any DC) is down.