P
Prasad Karunakaran
I have the following C# code to enumerate the list of groups in a
domain using ADSI. The problem is if the domain contains machine
accounts ($) it get those accounts too.
Can somebody help me here to filter out the machine accounts so that I
get only the NT group objects.
public ArrayList GetNTGroups()
{
DirectoryEntry ntDirectoryGroups = null;
try
{
ntDirectoryGroups = new DirectoryEntry(bindNTDomainPath,
bindNTUser, bindNTPassword);
ArrayList groupsArray = new ArrayList();
foreach(DirectoryEntry group in ntDirectoryGroups.Children)
{
switch(group.SchemaClassName.ToLower())
{
case "group" :
groupsArray.Add(group.Name);
break;
default :
break;
}
}
groupsArray.Sort();
return groupsArray;
}
catch(COMException ex)
{
return null;
}
finally
{
ntDirectoryGroups.Dispose();
}
}
Thanks,
Prasad
domain using ADSI. The problem is if the domain contains machine
accounts ($) it get those accounts too.
Can somebody help me here to filter out the machine accounts so that I
get only the NT group objects.
public ArrayList GetNTGroups()
{
DirectoryEntry ntDirectoryGroups = null;
try
{
ntDirectoryGroups = new DirectoryEntry(bindNTDomainPath,
bindNTUser, bindNTPassword);
ArrayList groupsArray = new ArrayList();
foreach(DirectoryEntry group in ntDirectoryGroups.Children)
{
switch(group.SchemaClassName.ToLower())
{
case "group" :
groupsArray.Add(group.Name);
break;
default :
break;
}
}
groupsArray.Sort();
return groupsArray;
}
catch(COMException ex)
{
return null;
}
finally
{
ntDirectoryGroups.Dispose();
}
}
Thanks,
Prasad