LookupSelector implements LdapEntrySelector { @Override public Iterable<LdapEntry> select(Connection connection) { final SearchRequest req = new SearchRequest(); req.setBaseDn(baseDn); req.setSearchFilter(new SearchFilter(filter)); req.setReturnAttributes(attributes); req.setSearchScope(SearchScope.SUBTREE); req.setTimeLimit(Duration.ofMillis(readPageTimeoutMs)); req.setSearchEntryHandlers(new ObjectGuidHandler()); return new PagedIterable(new PagedResultsClient(connection, pageSize), req); } LookupSelector(
      int pageSize, long readPageTimeoutMs, String baseDn, String filter, String... attributes); @Override Iterable<LdapEntry> select(Connection connection); @Override String toString();  }
@Test public void testLookupSelection() throws Exception { final LookupSelector selector = new LookupSelector( 10, 30_000L, server.getBaseDn(), "(&(objectClass=inetOrgPerson)(givenName=*))", "uid", "givenName"); try (Connection conn = connFactory.getConnection()) { conn.open(); final Set<LdapEntry> selection = StreamSupport.stream(selector.select(conn).spliterator(), false).collect(toSet()); assertEquals(selection.size(), 100); for (LdapEntry entry : selection) { assertNotNull(entry.getAttribute("givenName")); assertNotNull(entry.getAttribute("uid")); } } }