G
Guest
Hello all!
I'm attempting to write a method that will return an arraylist of security
group members. So, what I'd do is pass in a group and return an array. The
problem is, I can't figure out how to return the nt login (CORP\username),
instead I get:
CN=User Name,OU=Users,OU=Support Users,OU=Users and Computers
Here's wht my code is:
private ArrayList _GetADGroupUsers(string groupName)
{
SearchResult result;
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(cn={0})", groupName);
search.PropertiesToLoad.Add("member"); //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); //original
}
}
return userNames;
}
Help? Thanks!
I'm attempting to write a method that will return an arraylist of security
group members. So, what I'd do is pass in a group and return an array. The
problem is, I can't figure out how to return the nt login (CORP\username),
instead I get:
CN=User Name,OU=Users,OU=Support Users,OU=Users and Computers
Here's wht my code is:
private ArrayList _GetADGroupUsers(string groupName)
{
SearchResult result;
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(cn={0})", groupName);
search.PropertiesToLoad.Add("member"); //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); //original
}
}
return userNames;
}
Help? Thanks!