2013-06-18 80 views
1

我正在使用unboundid ldap sdk執行ldap查詢。運行ldap搜索查詢時遇到了一個奇怪的問題。當我針對包含50k個條目的組運行查詢時,我得到一個異常。我的例外:已超出LDAPException大小限制

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限制比爲什麼我收到這個錯誤? 我的代碼是

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

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

任何人有什麼想法?

+0

哪個LDAP服務器供應商? – jwilleke

回答

2

檢查服務器端大小限制設置。它勝過客戶端設置,這就是你在代碼中所做的事情。

3

對不起,你的主題沒有答案仍然是谷歌第一。

使用unboundid您實際上可以在尋呼模式下獲得無限數量的記錄。

public static void main(String[] args) { 

try { 
    int count = 0; 
    LDAPConnection connection = new LDAPConnection("hostname", 389, "[email protected]", "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()); 
} 

}

相關問題