超出 LDAPException 大小限制 [英] LDAPException size limit exceeded

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

问题描述

我正在使用 unboundid ldap sdk 来执行 ldap 查询.运行 ldap 搜索查询时遇到一个奇怪的问题.当我对包含 50k 个条目的组运行查询时出现异常.我的例外:

I am using unboundid ldap sdk for executing ldap query. I am facing a strange problem while running ldap search query. I am getting a Exception when i run query against a group which contains 50k entries. My Exception :

LDAPException(resultCode=4 (size limit exceeded), errorMessage='size limit exceeded')
at com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPSearchResults.nextElement(LDAPSearchResults.java:254)
at com.unboundid.ldap.sdk.migrate.ldapjdk.LDAPSearchResults.next(LDAPSearchResults.java:279)

现在奇怪的是,我已经在搜索约束中将 maxResultSize 设置为 100k,而不是为什么会出现此错误?我的代码是

Now the strange thing is i already have set the maxResultSize to 100k in search constrains than why i am getting this error ? My code is

     ld = new LDAPConnection();
    ld.connect(ldapServer, 389);

    LDAPSearchConstraints ldsc = new LDAPSearchConstraints();
    ldsc.setMaxResults(100000);
    ld.setSearchConstraints(ldsc);

有人知道吗?

推荐答案

抱歉发帖了,但是你没有回答的话题还是google第一.

Sorry for necroposting, but your topic with no answer is still the first in google.

使用unboundid实际上可以在分页模式下获得无限数量的记录.

Using unboundid you actually can get unlimited number of records in paging mode.

public static void main(String[] args) {

try {
    int count = 0;
    LDAPConnection connection = new LDAPConnection("hostname", 389, "user@domain", "password");

    final String path = "OU=Users,DC=org,DC=com";
    String[] attributes = {"SamAccountName","name"};

    SearchRequest searchRequest = new SearchRequest(path, SearchScope.SUB, Filter.createEqualityFilter("objectClass", "person"), attributes);

    ASN1OctetString resumeCookie = null;
    while (true)
    {
        searchRequest.setControls(
                new SimplePagedResultsControl(100, resumeCookie));
        SearchResult searchResult = connection.search(searchRequest);
        for (SearchResultEntry e : searchResult.getSearchEntries())
        {
            if (e.hasAttribute("SamAccountName"))
                System.out.print(count++ + ": " + e.getAttributeValue("SamAccountName"));

            if (e.hasAttribute("name"))
                System.out.println("->" + e.getAttributeValue("name"));
        }

        LDAPTestUtils.assertHasControl(searchResult,
                SimplePagedResultsControl.PAGED_RESULTS_OID);
        SimplePagedResultsControl responseControl =
                SimplePagedResultsControl.get(searchResult);
        if (responseControl.moreResultsToReturn())
        {
            resumeCookie = responseControl.getCookie();
        }
        else
        {
            break;
        }
    }


}
catch (Exception e)
{
    System.out.println(e.toString());
}

}

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

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