Changes the DN of an LDAP entry.
ModifyDnOperation modifyDn = new ModifyDnOperation(new DefaultConnectionFactory("ldap://directory.ldaptive.org")); ModifyDnResponse res = modifyDn.execute(ModifyDnRequest.builder() .oldDN("uid=dfisher,ou=people,dc=ldaptive,dc=org") .newRDN("uid=danielf") .delete(true) .build()); if (res.isSuccess()) { // modify succeeded } else { // modify failed }
The operation can be configured to throw so the result code doesn’t need to be checked.
ModifyDnOperation modifyDn = ModifyDnOperation.builder() .factory(new DefaultConnectionFactory("ldap://directory.ldaptive.org")) .throwIf(ResultPredicate.NOT_SUCCESS) .build(); modifyDn.execute(ModifyDnRequest.builder() .oldDN("uid=dfisher,ou=people,dc=ldaptive,dc=org") .newRDN("uid=danielf") .delete(true) .build());