DN userName = new DN( "uid=" + uid + ",ou=users,ou=system" );
LdapConnection userConnection = getConnectionAs( userName, password );
boolean isMoved = false;
ModifyDnResponse moveResp = userConnection.move( entryDN.getName(), newParentRdn + ",ou=system" );
if( moveResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
isMoved = true;
}
else
{
adminConnection.delete( entryDN );
return false;
}
ModifyDnResponse resp = userConnection.rename( entryRdn + "," + newParentRdn + ",ou=system", newNameRdn );
ResultCodeEnum code = resp.getLdapResult().getResultCode();
if( code == ResultCodeEnum.SUCCESS || code == ResultCodeEnum.ENTRY_ALREADY_EXISTS )
{
userConnection.delete( newNameRdn + "," + newParentRdn + ",ou=system" );
result = true;
}