Problem with DirectorySearcher

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.
 

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