I am using System.Security.Principal to identify clients and allow
functionality based on the groups they belong to. In one case I would like
to let them know who can do the function they cannot. How do I list the
members of a group?

Thanks
Tom

Re: A list of people in an active directory group. by Nick

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;
}