I am writing a .NET application to query an LDAP server, and I can't figure out how to look at exceptions and figure out what happened on the LDAP end. I'm using DirectoryServices, and trying to avoid anything that's specific to ActiveDirectory.
I create a DirectorySearcher, then do
try
{
SearchResult result = searcher.FindOne();
}
catch(Exception e)
{
// now what?
}
I expect certain types of errors to occur on the LDAP end, like user not found, account disabled, etc., and I'd like to identify these particular errors. Are there specific expection types?
I notice the innerException has a _COMPlusExceptionCode. Is this a reliable indicator of what went wrong on the LDAP side? I haven't been able to find an enumeration of these exception codes.
Any suggestions?