Delete Operation

Removes an LDAP entry from the directory.

DeleteOperation delete = new DeleteOperation(new DefaultConnectionFactory("ldap://directory.ldaptive.org"));
DeleteResponse res = delete.execute(DeleteRequest.builder()
  .dn("uid=dfisher,ou=people,dc=ldaptive,dc=org")
  .build());
if (res.isSuccess()) {
  // delete succeeded
} else {
  // delete failed
}

The operation can be configured to throw so the result code doesn’t need to be checked.

DeleteOperation delete = DeleteOperation.builder()
  .factory(new DefaultConnectionFactory("ldap://directory.ldaptive.org"))
  .throwIf(ResultPredicate.NOT_SUCCESS)
  .build();
delete.execute(DeleteRequest.builder()
  .dn("uid=dfisher,ou=people,dc=ldaptive,dc=org")
  .build());