When I try to access my LDAP server with the following C# code:
DirectoryEntry entry = new DirectoryEntry();
entry.Path = "LDAP Server and Path";
entry.Username = "userid";
entry.Password = "password";
DirectorySearcher ds = new DirectorySearcher(entry);
ds.Filter = string.Empty
ds.SearchScope = SearchScope.Subtree;
SearchResultCollection results = ds.FindAll();
I get DirectoryServicesCOMException thrown saying:
"A local error has occurred.".
After having done some investigation, I notice the above code did not specify the AuthenticationType value, it seems that my Windows Server 2008 security doesn't like the default value in the AuthenticationType.
Assigning None value to the AuthenticationType will get rid of the exception.
DirectoryEntry entry = new DirectoryEntry();
entry.Path = "LDAP Server and Path";
entry.Username = "userid";
entry.Password = "password";
entry.AuthenticationType = AuthenticationTypes.None;