Nick
Wed Jul 11 13:53:10 CDT 2007
http://www.codeproject.com/dotnet/QueryADwithDotNet.asp
Let's get a list of users belonging to a particular AD group. The code below
shows how to do this:
ArrayList GetADGroupUsers(string groupName)
{ SearchResult result;
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(cn={0})", groupName);
search.PropertiesToLoad.Add("member");
result = search.FindOne();
ArrayList userNames = new ArrayList();
if (result != null)
{
for (int counter = 0; counter <
result.Properties["member"].Count; counter++)
{
string user = (string)result.Properties["member"][counter];
userNames.Add(user);
}
}
return userNames;
}