[英]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.