Exception at DirectorySearcher.FindOne

  • Thread starter Thread starter Carsten Witte
  • Start date Start date
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
 
DirectorySearcher search = new DirectorySearcher(entry,
"(objectCategory=computer)(name=perseus)");

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