08 Mar 2010
25 May 2010
Link to this post
I found that if the DN contains a '/' character, a COMException is thrown when this method calls DirectorySearcher.FindOne(). I fixed this using dn.Replace("/", "\\/") when creating the DirectoryEntry, and it solved my problem.
Perhaps it is best practice to not include slash characters in active directory, but it's unclear from the LDAP RFC that this is illegal, and the ability of other Microsoft to insert these makes it a case necessary to handle. In my opinion it's a bug in DirectorySearcher, but this workaround appears to help in our situation.