我需要使用 System.DirectoryServices 类迭代组的成员。
我看到的问题是,在获得该组的 DirectoryEntry 后,“members”属性仅包含 1500 个条目。事实上,该团体有超过 4000 人。
是否有一些设置告诉 DirectoryServices 类不要检索超过 1500 个组成员?
最佳答案
如果可以,请尝试使用 .NET 3.5 中的 System.DirectoryServices.AccountManagement
命名空间。我没有这么大的团体可供尝试 - 但你应该能够获得这些成员:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity("name of the group");
if(group != null)
{
foreach(Principal p in group.Members)
{
// do something
}
}
您可以在 MSDN 杂志上阅读有关 S.DS.AM 命名空间及其新功能的更多信息:Managing Directory Security Principals in the .NET Framework 3.5
关于c# - 迭代事件目录中大型组的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4146902/