Search in sources :

Example 6 with LDAPModification

use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.

the class JLDAPProviderImpl method writeBinaryAttribute.

@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void writeBinaryAttribute(final String entryDN, final String attribute, final byte[][] values, final boolean overwrite, final ChaiRequestControl[] controls) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
    activityPreCheck();
    getInputValidator().writeBinaryAttribute(entryDN, attribute, values, overwrite);
    final LDAPAttribute ldapAttr = new LDAPAttribute(attribute);
    for (final byte[] value : values) {
        ldapAttr.addValue(value);
    }
    final LDAPModification mod = new LDAPModification(overwrite ? LDAPModification.REPLACE : LDAPModification.ADD, ldapAttr);
    try {
        if (controls != null && controls.length > 0) {
            final LDAPConstraints constraints = new LDAPConstraints();
            constraints.setControls(convertControls(controls));
            ldapConnection.modify(entryDN, mod, constraints);
        } else {
            ldapConnection.modify(entryDN, mod);
        }
    } catch (LDAPException e) {
        throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPException(com.novell.ldap.LDAPException) LDAPConstraints(com.novell.ldap.LDAPConstraints) LDAPModification(com.novell.ldap.LDAPModification)

Aggregations

LDAPAttribute (com.novell.ldap.LDAPAttribute)6 LDAPException (com.novell.ldap.LDAPException)6 LDAPModification (com.novell.ldap.LDAPModification)6 LDAPConstraints (com.novell.ldap.LDAPConstraints)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1