Directory Notification

Active Directory provides a control for clients to register to receive changes notifications. Note the following constraints when configuring your search:

scope Must be one-level or object-level
filter Must be ‘(objectClass=*)’
attributes list of attributes to be returned when a change occurs. Does not specify attributes which will generate notifications.

A notification client is provided to encapsulate the asynchronous search and expose a blocking queue.


SingleConnectionFactory factory = new SingleConnectionFactory(ConnectionConfig.builder()
    new BindConnectionInitializer("cn=manager,ou=people,dc=ldaptive,dc=org", new Credential("manager_password")))
NotificationClient client = new NotificationClient(factory);
SearchRequest request = SearchRequest.builder()
BlockingQueue<NotificationClient.NotificationItem> results = client.execute(request);
while (true) {
  NotificationClient.NotificationItem item = results.take(); // blocks until result is received
  if (item.isEntry()) {
    LdapEntry entry = item.getEntry();
  } else if (item.isException()) {