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.

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

CompareOperation compare = new CompareOperation(new DefaultConnectionFactory("ldap://directory.ldaptive.org"));
CompareResponse res = compare.execute(CompareRequest.builder()
  .dn("uid=dfisher,ou=people,dc=ldaptive,dc=org")
  .name("mail")
  .value("dfisher@ldaptive.org")
  .build());
if (res.isTrue()) {
  // compare succeeded
} else {
  // compare failed
}