Session Tracking

Include tracking information about a client session in an LDAP operation. See Draft RFC.

Using the Session Tracking Control

When binding and the user is not yet known

Connection conn = DefaultConnectionFactory.getConnection("ldap://directory.ldaptive.org");
try {
  conn.open();
  BindOperation bind = new BindOperation(conn);
  BindRequest request = new BindRequest(
    "uid=dfisher,ou=people,dc=ldaptive,dc=org", new Credential("password"));
  request.setControls(
    new SessionTrackingControl(
      "151.101.32.133", // client IP address
      "hostname.domain.com", // client host name, empty string if unknown
      SessionTrackingControl.USERNAME_ACCT_OID, // must assign an OID even if using an empty identifier
      "")); // empty tracking identifier
  bind.execute(request);
} finally {
  conn.close();
}

When searching and the user is known

Connection conn = DefaultConnectionFactory.getConnection("ldap://directory.ldaptive.org");
try {
  conn.open();
  SearchOperation search = new SearchOperation(conn);
  SearchRequest request = new SearchRequest("dc=ldaptive,dc=org", new SearchFilter("(givenName=daniel)"));
  request.setControls(
    new SessionTrackingControl(
      "151.101.32.133", // client IP address
      "hostname.domain.com", // client host name, empty string if unknown
      SessionTrackingControl.USERNAME_ACCT_OID,
      "dn:uid=dfisher,ou=people,dc=ldaptive,dc=org"));
  SearchResult result = search.execute(request).getResult();
  for (LdapEntry entry : result.getEntries()) {
    // do something useful with the entries
  }
} 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