use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.
the class JLDAPProviderImpl method deleteStringAttributeValue.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void deleteStringAttributeValue(final String entryDN, final String attribute, final String value) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().deleteStringAttributeValue(entryDN, attribute, value);
final LDAPAttribute ldapAttr = new LDAPAttribute(attribute, value);
final LDAPModification mod = new LDAPModification(LDAPModification.DELETE, ldapAttr);
try {
ldapConnection.modify(entryDN, mod);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.
the class JLDAPProviderImpl method replaceStringAttribute.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void replaceStringAttribute(final String entryDN, final String attributeName, final String oldValue, final String newValue) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().replaceStringAttribute(entryDN, attributeName, oldValue, newValue);
final LDAPModification[] modifications;
modifications = new LDAPModification[2];
modifications[0] = new LDAPModification(LDAPModification.DELETE, new LDAPAttribute(attributeName, oldValue));
modifications[1] = new LDAPModification(LDAPModification.ADD, new LDAPAttribute(attributeName, newValue));
try {
ldapConnection.modify(entryDN, modifications);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.
the class JLDAPProviderImpl method writeStringAttribute.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void writeStringAttribute(final String entryDN, final String attribute, final Set<String> values, final boolean overwrite) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().writeStringAttribute(entryDN, attribute, values, overwrite);
final LDAPAttribute ldapAttr = new LDAPAttribute(attribute, values.toArray(new String[values.size()]));
final LDAPModification mod = new LDAPModification(overwrite ? LDAPModification.REPLACE : LDAPModification.ADD, ldapAttr);
try {
ldapConnection.modify(entryDN, mod);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.
the class JLDAPProviderImpl method replaceBinaryAttribute.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void replaceBinaryAttribute(final String entryDN, final String attribute, final byte[] oldValue, final byte[] newValue) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException {
activityPreCheck();
getInputValidator().replaceBinaryAttribute(entryDN, attribute, oldValue, newValue);
final LDAPModification[] modifications;
modifications = new LDAPModification[2];
modifications[0] = new LDAPModification(LDAPModification.DELETE, new LDAPAttribute(attribute, oldValue));
modifications[1] = new LDAPModification(LDAPModification.ADD, new LDAPAttribute(attribute, newValue));
try {
ldapConnection.modify(entryDN, modifications);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPModification in project ldapchai by ldapchai.
the class JLDAPProviderImpl method writeStringAttributes.
@LdapOperation
@ModifyOperation
public final void writeStringAttributes(final String entryDN, final Map<String, String> attributeValues, final boolean overwrite) throws ChaiUnavailableException, ChaiOperationException {
activityPreCheck();
getInputValidator().writeStringAttributes(entryDN, attributeValues, overwrite);
final int modOption = overwrite ? LDAPModification.REPLACE : LDAPModification.ADD;
final List<LDAPModification> modifications = new ArrayList<>();
for (final Map.Entry<String, String> entry : attributeValues.entrySet()) {
final String attrName = entry.getKey();
final LDAPAttribute ldapAttr = new LDAPAttribute(attrName, entry.getValue());
final LDAPModification mod = new LDAPModification(modOption, ldapAttr);
modifications.add(mod);
}
final LDAPModification[] modificationArray = modifications.toArray(new LDAPModification[modifications.size()]);
try {
ldapConnection.modify(entryDN, modificationArray);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
Aggregations