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);
}
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;
}
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);
}
Aggregations