I have a ASP.NET Website project and I need to list all the users and their groups on my Windows system. I have set the identity impersonation to true and provided the usern
This article covers how to talk to Active Directory and should get you where you want to go: http://www.codeproject.com/KB/system/everythingInAD.aspx
To get users, you would do something like this:
public List GetUserList()
{
string DomainName="";
string ADUsername="";
string ADPassword="";
List list=new List();
DirectoryEntry entry=new DirectoryEntry(LDAPConnectionString, ADUsername, ADPassword);
DirectorySearcher dSearch=new DirectorySearcher(entry);
dSearch.Filter="(&(objectClass=user))";
foreach(SearchResult sResultSet in dSearch.FindAll())
{
string str=GetProperty(sResultSet, "userPrincipalName");
if(str!="")
list.Add(str);
}
return list;
}