DirectoryEntry页面大小限制 [英] DirectoryEntry Page Size limit

查看:134
本文介绍了DirectoryEntry页面大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码可以正常工作,但是正在发生的事情是该代码将结果限制为1500个用户,而我们有1500多个用户。我要尝试的是检索属于特定组的所有用户的列表。我知道 DirectorySearcher 具有PageSize设置,但是我无法找到一种方法来设置DirectoryEntry PageSize仍将仅拉该组的成员。

The code below works just fine, however what's happening is the code limits the results to 1500 users and we have more than 1500 users. What I'm trying to do is retrieve a list of all users that are a member of a specific group. I know DirectorySearcher has a PageSize setting however, I'm unable to find a way to set DirectoryEntry PageSize will still only pulling members of that group.

有人知道改变页面大小的方法吗?或者也许如何以另一种方式来拉特定群组的成员以适应页面大小?

Does anybody know a way to change the page size? Or maybe how to pull members of a specific group in another fashion that will accommodate pagesize?

DirectoryEntry dEntryhighlevel = new DirectoryEntry("LDAP://CN=Users,OU=MyOu,OU=Clients,OU=Home,DC=bridgeTech,DC=net");
foreach (object dn in dEntryhighlevel.Properties["member"])
{
    DirectoryEntry singleEntry = new DirectoryEntry("LDAP://" + dn);
    DirectorySearcher dSearcher = new DirectorySearcher(singleEntry);
    //filter just user objects
    dSearcher.SearchScope = SearchScope.Base;
    //dSearcher.Filter = "(&(objectClass=user)(dn=" + dn + "))";
    //dSearcher.PageSize = 1000;
    SearchResult singleResult = null;
    singleResult = dSearcher.FindOne();
    if (singleResult != null)
    {
        string Last_Name = singleResult.Properties["sn"][0].ToString();
        string First_Name = singleResult.Properties["givenname"][0].ToString();
        string userName = singleResult.Properties["samAccountName"][0].ToString();
        string Email_Address = singleResult.Properties["mail"][0].ToString();
        OriginalList.Add(Last_Name + "|" + First_Name + "|" + userName + "|" + Email_Address);
    }
    singleEntry.Close();
}


推荐答案

我正在研究某些东西目前与此类似,并注意到您的代码略有不同。使用以下代码结构,结果不会出现任何问题:

I'm working on something similar to this at the moment and noticed that your code differs to mine slightly. I haven't had any issues with limited results using the following code structure:

DirectoryEntry dEntryhighlevel = new DirectoryEntry("LDAP://CN=Users,OU=MyOu,OU=Clients,OU=Home,DC=bridgeTech,DC=net");
DirectorySearcher dSearcher = new DirectorySearcher();
//filter just user objects
dSearcher.Filter = "(objectClass=user)";
dSearcher.PageSize = 1000;
SearchResultCollection resultCollection = dirSearcher.FindAll();
foreach (SearchResult userResults in resultCollection )
{
    string Last_Name = userResults .Properties["sn"][0].ToString();
    string First_Name = userResults .Properties["givenname"][0].ToString();
    string userName = userResults .Properties["samAccountName"][0].ToString();
    string Email_Address = userResults .Properties["mail"][0].ToString();
    OriginalList.Add(Last_Name + "|" + First_Name + "|" + userName + "|" + Email_Address);
}

应该返回所有用户。您需要在 dSearcher.Filter 中使用LDAP搜索模式,才能将用户缩小到特定的组-请参阅此链接,以获取其他帮助。

That should return all your users. You'll need to use LDAP search patterns in your dSearcher.Filter in order to narrow users down to a specific group - see this link for some additional help with that.

这篇关于DirectoryEntry页面大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆