Search in sources :

Example 1 with LDAPAttribute

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());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPException(com.novell.ldap.LDAPException) LDAPModification(com.novell.ldap.LDAPModification)

Example 2 with LDAPAttribute

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());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPException(com.novell.ldap.LDAPException) LDAPModification(com.novell.ldap.LDAPModification)

Example 3 with LDAPAttribute

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());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPException(com.novell.ldap.LDAPException) LDAPModification(com.novell.ldap.LDAPModification)

Example 4 with LDAPAttribute

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());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPEntry(com.novell.ldap.LDAPEntry) LDAPException(com.novell.ldap.LDAPException) LDAPAttributeSet(com.novell.ldap.LDAPAttributeSet) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 5 with LDAPAttribute

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());
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPException(com.novell.ldap.LDAPException) LDAPModification(com.novell.ldap.LDAPModification)

Aggregations

LDAPAttribute (com.novell.ldap.LDAPAttribute)14 LDAPException (com.novell.ldap.LDAPException)12 LDAPModification (com.novell.ldap.LDAPModification)6 LDAPEntry (com.novell.ldap.LDAPEntry)5 LDAPAttributeSet (com.novell.ldap.LDAPAttributeSet)4 LinkedHashMap (java.util.LinkedHashMap)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Iterator (java.util.Iterator)2 List (java.util.List)2 LDAPConstraints (com.novell.ldap.LDAPConstraints)1 LDAPSearchConstraints (com.novell.ldap.LDAPSearchConstraints)1 LDAPSearchResults (com.novell.ldap.LDAPSearchResults)1 SearchHelper (com.novell.ldapchai.util.SearchHelper)1 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)1 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)1 IOException (java.io.IOException)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1