Exception at DirectorySearcher.FindOne

C

Carsten Witte

Hello,

with Windows UI (dialog "Select Users, Computers, or Groups ) I can
search the LDAP for any given computer name, displaying all kinds of
columns, i.a. "managed by"). Anyway, if I try that in code, I get an
exception: 0x8007200, "The directory service is unavailable." I guess,
I created a malformed search, so here is the code:

Domain domain = Domain.GetCurrentDomain();
DirectoryEntry entry = domain.GetDirectoryEntry();
DirectorySearcher search = new DirectorySearcher(entry,
"(objectCategory=computer)(name=perseus)");
SearchResult result= search.FindOne();

Bam!

Any ideas? I know that's more or less an LDAP-question, but I saw
similar issues solved here, too. I would highly appreciate additional
pointer to "LDAP for Dummies" as I would want to improve the search by
just return the property I really need, but do have no idea what the
correct property-names for "computer" are and so on...

TIA, Carsten
 
C

Carsten Witte

DirectorySearcher search = new DirectorySearcher(entry,
"(objectCategory=computer)(name=perseus)");

D'oh! Of course this has to read "(&(objectCategory=computer)
(name=perseus))" My bad...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top