hi, I'm having trouble retrieving the members of a certain group in active directory. The code im usinf is the following
[Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "fillRow")]
public static IEnumerable getNTGroupMembers(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++)
{
object user = (object)result.Properties["member"][counter];
userNames.Add(user);
}
}
return userNames;
}
but it returns me a list of the following:
CN=X,OU=x,OU=X,OU=X,OU=X,DC=X,DC=X,DC=X
Does anyone know how i can return the members username. I've tried getting different properties, but i haven't being able to get to work.
This is part of a clr function I'm doing for sql server 2005.