Hello,

I have a method that is used to find all of the distribution lists and
security groups that a user belongs to. This 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?

--
Michael Bayha

Re: DirectorySearcher.FindOne() fails when LDAP path contains "/" by Lionel

Lionel
Wed Mar 23 15:33:50 CST 2005


It look like a known problem. See
http://www.error-bank.com/microsoft.public.dotnet.framework/bvl2dr$dim$2@news.dtag.de_Thread.aspx

Lionel.

"mbayha" <mbayha@discussions.microsoft.com> a écrit dans le message de news:
5DF6B170-19C4-4294-B586-81C0C4A0FCCD@microsoft.com...
> Hello,
>
> I have a method that is used to find all of the distribution lists and
> security groups that a user belongs to. This 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?
>
> --
> Michael Bayha



Re: DirectorySearcher.FindOne() fails when LDAP path contains "/" by Marc

Marc
Thu Mar 24 09:02:47 CST 2005

>I have a method that is used to find all of the distribution lists and
>security groups that a user belongs to. This 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

The forward slash is a special character that LDAP normally uses for
internal purposes, as a separator between certain bits of the LDAP
string. That's why it gets confused if an object name suddenly
contains a /

You can try to "escape" it with a \ - so replace your forward slash
with a backslash-forward slash combo.

This also applies to a number of other special chars in LDAP, such as
comma (,), dot (.), equal sign (=), and a few more.

Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch