我如何取一个校长,看看它是否是一个团体?或者它有成员?
using(var ctx = new PrincipalContext(ContextType.Domain, "some.domain.com", "DC=some,DC=domain,DC=com"))
{
var group = GroupPrincipal.FindByIdentity(ctx, IdentityType.DistinguishedName, "some long distinguishedname");
if(group != null)
{
var subgroups = group.GetMembers().Where(m => m.[IS A GROUP])
foreach (var principal in group.GetMembers())
{
Console.WriteLine(principal.DistinguishedName);
}
}
}