Search in sources :

Example 1 with ModifyRequest

use of com.unboundid.ldap.sdk.ModifyRequest in project zm-mailbox by Zimbra.

the class UBIDLdapContext method testAndModifyAttributes.

@Override
public boolean testAndModifyAttributes(String dn, ZModificationList modList, ZLdapFilter testFilter) throws LdapException {
    try {
        ModifyRequest modReq = new ModifyRequest(dn, ((UBIDModificationList) modList).getModList());
        modReq.addControl(new AssertionRequestControl(((UBIDLdapFilter) testFilter).getNative()));
        LDAPResult result = UBIDLdapOperation.TEST_AND_MODIFY_ATTRS.execute(this, modReq);
        return true;
    } catch (LDAPException e) {
        if (e.getResultCode() == ResultCode.ASSERTION_FAILED) {
            // The modification failed because the the filter does not match the target entry
            return false;
        } else {
            // The modification failed for some other reason.
            throw mapToLdapException("unable to test and modify attributes", e);
        }
    }
}
Also used : AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest)

Aggregations

LDAPException (com.unboundid.ldap.sdk.LDAPException)1 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)1 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)1 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)1