简体   繁体   English

如何使用 C# 从 Active Directory 组中检索 3000 多个用户详细信息?

[英]How to retrieve more than 3000 user details from an Active Directory group using C#?

I have an Active Directory group with more than 3000 members in it.我有一个 Active Directory 组,其中有 3000 多个成员。 I want to retrieve all those members from that group using the LDAP connection.我想使用 LDAP 连接从该组中检索所有这些成员。 I tried using the below snippet but it is providing one 1-1499 members from the group.我尝试使用以下代码段,但它提供了该组中的一个 1-1499 成员。 Is there is any other way to achieve the same有没有其他方法可以达到同样的效果

LdapConnection connection = new LdapConnection(********);
NetworkCredential cred = new NetworkCredential(********, ********, ********);
connection.Credential = cred;

List<SearchResponse> results = new List<SearchResponse>();
SearchRequest request = new SearchRequest("***********", "(objectClass=group)", System.DirectoryServices.Protocols.SearchScope.Subtree, new string[] {"member" });

PageResultRequestControl prc = new PageResultRequestControl(1000);
SearchOptionsControl soc = new SearchOptionsControl(System.DirectoryServices.Protocols.SearchOption.DomainScope);
request.Controls.Add(prc);
request.Controls.Add(soc);

while (true)
{
       SearchResponse response = connection.SendRequest(request) as SearchResponse;

       foreach (DirectoryControl control in response.Controls)
       {
           if (control is PageResultResponseControl)
           {
                prc.Cookie = ((PageResultResponseControl)control).Cookie;
                break;
           }
       }

       foreach (var item in response.Entries[0].Attributes["member"].GetValues(typeof(String)))
       {
            var t = item;
       }

       results.Add(response);
}

Appears that you are hitting the MaxValRange limits.看来您正在达到 MaxValRange 限制。 MaxValRange value controls the number of values that are returned for an attribute of an object, independent of how many attributes that object has, or of how many objects were in the search result. MaxValRange 值控制为对象的属性返回的值的数量,与该对象具有的属性数量或搜索结果中的对象数量无关。

I do not do C# but We have a sample in Java code that may be helpful.我不使用 C#,但我们有一个Java 代码示例可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#检索Active Directory组中的所有用户 - Retrieve all the users in an Active Directory group using C# C# - 使用 LDAP 检索 Active Directory 的组成员 - C# - Retrieve Group members of Active Directory using LDAP 如何在C#中获取当前用户的Active Directory详细信息 - How to get the current user's Active Directory details in C# 如何使用 C# 中的 UserPrincipal 获取 Active Directory 中的地址详细信息 - How to get details of address in Active Directory using UserPrincipal in C# 如何使用C#识别组的成员是Active Directory中的用户还是组 - How to identify if member of a group is a user or group in Active Directory using C# C#将活动目录用户添加到组 - C# add active directory user to group 如何使用 C# 过滤掉 Active Directory 中的内置用户(访客)和组(管理员)? - How to filter out built in user(Guest) and group(Admin) in Active Directory using C#? 如何使用C#在Active Directory中检索schemaNamingMaster? - How do I retrieve the schemaNamingMaster in Active Directory using C#? .net:如何使用C#将用户添加到Active Directory安全组? - .net : How to add a user to a Active Directory Security Group using C#? c# 从文件夹中的多个 csv 文件中检索详细信息 - c# Retrieve details from more than one csv file in a folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM