use of com.novell.ldap.LDAPAttribute 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.LDAPAttribute 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.LDAPAttribute 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.LDAPAttribute in project ldapchai by ldapchai.
the class JLDAPProviderImpl method createEntry.
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
public void createEntry(final String entryDN, final Set<String> baseObjectClasses, final Map<String, String> stringAttributes) throws ChaiOperationException {
activityPreCheck();
getInputValidator().createEntry(entryDN, baseObjectClasses, stringAttributes);
final LDAPAttributeSet ldapAttributeSet = new LDAPAttributeSet();
ldapAttributeSet.add(new LDAPAttribute(ChaiConstant.ATTR_LDAP_OBJECTCLASS, baseObjectClasses.toArray(new String[baseObjectClasses.size()])));
if (stringAttributes != null) {
for (final Map.Entry<String, String> entry : stringAttributes.entrySet()) {
final String attrName = entry.getKey();
ldapAttributeSet.add(new LDAPAttribute(attrName, entry.getValue()));
}
}
final LDAPEntry newEntry = new LDAPEntry(entryDN, ldapAttributeSet);
try {
ldapConnection.add(newEntry);
} catch (LDAPException e) {
throw ChaiOperationException.forErrorMessage(e.getLDAPErrorMessage());
}
}
use of com.novell.ldap.LDAPAttribute 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());
}
}
Aggregations