Problem with DirectorySearcher

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Hi,

i'm trying to connect to the Active Directory and perform searches
using C# but i'm getting an error when dealing with DirectorySearcher
class. Here is a piece of code:

DirectoryEntry de = new DirectoryEntry
("LDAP://OU=MYOU,DC=MYDOMAIN,DC=local", "superuser", "password");

### This works OK

DirectorySearcher ds = new DirectorySearcher
("(&(objectCategory=person)(objectclass=user))");

### OK again

ds.searchRoot = de;

### Not OK -- retrieving "CS0122:
'System.DirectoryServices.DirectorySearcher.searchRoot' is inaccessible
due to its protection level" when compiling.

I searched in the class browser and the class DirectorySearcher is
defined as 'public' as soon as all the properties themselves (.searchRoot
included), so why this message?

Thanks in advance.
 
Back
Top