-1

i want to have a list of all users in the active directory in the server and use it in my c# application

string DomainPath = "LDAP://192.168.1.250/Domain";
DirectoryEntry searchRoot = new DirectoryEntry(DomainPath,"user","password");

this code don't work

Jenish Rabadiya
  • 6,708
  • 6
  • 33
  • 62
mokhtar nebli
  • 25
  • 1
  • 6

1 Answers1

1

Add the following code

DirectorySearcher search = new DirectorySearcher(searchRoot);
search.Filter = "(&(objectClass=user)(objectCategory=person))";

In DirectorySearcher, create a DirectorySearcher object which searches for all users in a domain. search.Filter = "(&(objectClass=user)(objectCategory=person))" filters the search.

Earth
  • 3,477
  • 6
  • 37
  • 78