Exception thrown using DirectorySearcher.FindOne()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a method that is used to find all of the distribution lists and
security groups that a user belongs to. The works fine, except when the LDAP
path looks like the following:

CN=aaa/ aaaaa,OU=Distribution Lists,DC=string,DC=string,DC=string,DC=com

I've found that everytime the DirecotrySearcher.FindOne() encounters a path
that contains a '/' in the CN portion, it throws an exception. Below is the
exception:

Source: System.DirectoryServices
Message: Unknown error (0x80005000)
Stack Trace: at System.DirectoryServices.DirectoryEntry.Bind(Boolean
throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at
System.DirectoryServices.DirectoryEntry.get_AdsObject()
at
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at
System.DirectoryServices.DirectorySearcher.FindOne()
at ADUtilityTester.ADUtilities.getDLList(String
sDomain, String sUser) in c:\\documents and settings\\username\\my
documents\\visual studio projects\\adutilitytester\\adutilities.cs:line 74

Line 74 is:

SearchResult schRes = ds2.FindOne();

I've tried escaping it, but then it just doesn't find anything.

Any ideas on how to get around this problem?
 
Back
Top