Wasting time with .NET Directory Services.
Published 5.10.2007 by ~mattg
As of late, some new features have been requested of our LDAP implementation, and since I was the last one to touch that code, I got to look into the improvements. The task seemed fairly easy, but some of my LDAP requests kept failing with the wonderfully informative “Unknown error (0×80005000)” error. I thought maybe I was disposing of the directory services objects improperly, so I rearranged a bunch of code, but still got the same error.
As it turns out, the System.DirectoryServices namespace is simply a wrapper for the Active Directory Service Interface (ADSI) group of COM interfaces. Apparently, the syntax for these objects is incredibly fickle. How fickle? Well, take the following links:
- LDAP://ldapserver:389/
- LDAP://ldapserver:389
The difference (the trailing slash) seems insignificant, but feed that first link to a DirectoryEntry object and watch the “Unknown Errors” pop up. The second one, however, works perfectly. I spent at least three hours trying to figure out the source of that error. Luckily, others have had similar issues with Active Directory syntax, and that post helped me find my own syntax errors.
All in all, it’s a terrible waste of time when better error messages and/or documentation would have helped me out tremendously.
Filed under .NET Development, Windows
You’re right - it is all these little (seemingly) insignificant things that can easily trip someone up. You’re not the only one feeling the pain!