Search in sources :

Example 21 with ModificationItem

use of javax.naming.directory.ModificationItem in project fess by codelibs.

the class LdapManager method modifyReplaceEntry.

protected void modifyReplaceEntry(final List<ModificationItem> modifyList, final String name, final String value) {
    final Attribute attr = new BasicAttribute(name, value);
    final ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);
    modifyList.add(mod);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) ModificationItem(javax.naming.directory.ModificationItem) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute)

Example 22 with ModificationItem

use of javax.naming.directory.ModificationItem in project fess by codelibs.

the class LdapManager method changePassword.

public boolean changePassword(final String username, final String password) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    if (!fessConfig.isLdapAdminEnabled(username)) {
        return false;
    }
    final Supplier<Hashtable<String, String>> adminEnv = () -> createAdminEnv();
    final String userDN = fessConfig.getLdapAdminUserSecurityPrincipal(username);
    search(fessConfig.getLdapAdminUserBaseDn(), fessConfig.getLdapAdminUserFilter(username), null, adminEnv, result -> {
        if (!result.isEmpty()) {
            final List<ModificationItem> modifyList = new ArrayList<>();
            modifyReplaceEntry(modifyList, "userPassword", password);
            modify(userDN, modifyList, adminEnv);
        } else {
            throw new LdapOperationException("User is not found: " + username);
        }
    });
    return true;
}
Also used : ModificationItem(javax.naming.directory.ModificationItem) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) LdapOperationException(org.codelibs.fess.exception.LdapOperationException) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 23 with ModificationItem

use of javax.naming.directory.ModificationItem in project fess by codelibs.

the class LdapManager method modifyAddEntry.

protected void modifyAddEntry(final List<ModificationItem> modifyList, final String name, final String value) {
    final Attribute attr = new BasicAttribute(name, value);
    final ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
    modifyList.add(mod);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) ModificationItem(javax.naming.directory.ModificationItem) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute)

Aggregations

ModificationItem (javax.naming.directory.ModificationItem)23 BasicAttribute (javax.naming.directory.BasicAttribute)19 Attribute (javax.naming.directory.Attribute)12 ArrayList (java.util.ArrayList)5 NamingException (javax.naming.NamingException)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)3 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)3 SMSException (com.sun.identity.sm.SMSException)3 Hashtable (java.util.Hashtable)3 LinkedHashSet (java.util.LinkedHashSet)3 Attributes (javax.naming.directory.Attributes)3 DirContext (javax.naming.directory.DirContext)3 LdapOperationException (org.codelibs.fess.exception.LdapOperationException)3 Base64 (java.util.Base64)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Locale (java.util.Locale)2