Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get a list of all the users on a domain using ASP.NET with C# as the backend?

Tags:

c#

asp.net

The question basically says it all. I want to be able to get a list of all the users on the windows domain (i.e. in the active directory) using c#.

Thanks!

like image 839
adhanlon Avatar asked Oct 12 '22 16:10

adhanlon


1 Answers

var dirEntry = new DirectoryEntry(string.Format("LDAP://{0}/{1}", "x.y.com", "DC=x,DC=y,DC=com"));
var searcher = new DirectorySearcher(dirEntry)
         {
             Filter = "(&(&(objectClass=user)(objectClass=person)))"
         };
var resultCollection = searcher.FindAll();

SEE: Get all users from AD domain

like image 122
John K. Avatar answered Oct 14 '22 13:10

John K.