Persistent Search

Request that the server keep a search operation open and send changes to the client. See A Simple LDAP Change Notification Mechanism.

Using the Persistent Search Client

Connection conn = DefaultConnectionFactory.getConnection("ldap://directory.ldaptive.org");
try {
  conn.open();
  // only return changed entries, return the entry change control
  PersistentSearchClient client = new PersistentSearchClient(conn, EnumSet.allOf(PersistentSearchChangeType.class), true, true);
  SearchRequest request = SearchRequest.newObjectScopeSearchRequest("dc=ldaptive,dc=org");
  BlockingQueue<PersistentSearchItem> results = client.execute(request);
  while (true) {
    PersistentSearchItem item = results.take(); // blocks until result is received
    if (item.isEntry()) {
      EntryChangeNotificationControl nc = item.getEntry().getEntryChangeNotificationControl();
      LdapEntry entry = item.getEntry().getSearchEntry();
      // process this entry with the entry change control data
    } else if (item.isResponse()) {
      // response received
      break;
    } else if (item.isAsyncRequest()) {
      // request has begun
      AsyncRequest ar = item.getAsyncRequest();
    } else if (item.isException()) {
      // an error has occurred
      throw item.getException();
    }
  }
} finally {
  conn.close();
}

Provider Support

JNDI JLDAP Apache LDAP UnboundID OpenDJ
Functionality exists in the provider API and has been confirmed
Functionality does not exist in the provider API
Functionality exists in the provider API, but did not work in our test environment
? Functionality exists in the provider API, but has not been integrated into the ldaptive provider