Compare Operation

Determines if an entry contains a specific attribute and value. An LDAP attribute may contain sensitive information which a client is not allowed to read, but is allowed to compare. Note that compare only uses a single attribute value, but the LdapAttribute object may contain more than one value. This implementation only uses the first value, all other values are ignored.

Compares the mail: attribute on the entry uid=dfisher,ou=people,dc=ldaptive,dc=org

Connection conn = DefaultConnectionFactory.getConnection("ldap://");
try {;
  CompareOperation compare = new CompareOperation(conn);
  boolean success = compare.execute(
    new CompareRequest(
    "uid=dfisher,ou=people,dc=ldaptive,dc=org", new LdapAttribute("mail", ""))).getResult();
  // do something useful with the result
} finally {