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

查看:706
本文介绍了超出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天全站免登陆