Posted By

nialace on 04/13/11


Tagged

ldap unboundid


Versions (?)

ldap search with pagination (using UnboundID)


 / Published in: Java
 

URL: http://www.unboundid.com

UnboundID LDAP SDK

  1. public class Main {
  2.  
  3. /**
  4.   * @param args
  5.   * @throws LDAPException
  6.   */
  7. public static void main(String[] args) throws LDAPException {
  8.  
  9.  
  10. LDAPConnection connection = new LDAPConnection("192.168.9.164", 1389, "cn=admin4directory,dc=ilex-si,dc=eu", "M3d2p5a4!");
  11.  
  12. SearchRequest searchRequest =
  13. new SearchRequest("ou=people,dc=ilex-si,dc=eu", SearchScope.SUB,"(ixuid=*)");
  14.  
  15. ASN1OctetString cookie = null;
  16. do
  17. {
  18. searchRequest.setControls(
  19. new Control[] { new SimplePagedResultsControl(500, cookie) });
  20. SearchResult searchResult = connection.search(searchRequest);
  21.  
  22. // Do something with the entries that are returned.
  23.  
  24. cookie = null;
  25. for (Control c : searchResult.getResponseControls())
  26. {
  27. if (c instanceof SimplePagedResultsControl)
  28. {
  29. cookie = ((SimplePagedResultsControl) c).getCookie();
  30. }
  31. }
  32. } while ((cookie != null) && (cookie.getValueLength() > 0));
  33.  
  34.  
  35. connection.close();
  36.  
  37. }
  38.  
  39. }

Report this snippet  

You need to login to post a comment.