Search in sources :

Example 11 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-fortress-core by apache.

the class UserDAO method deleteResetFlag.

/**
 *1     * @param user
 * @throws UpdateException
 */
private void deleteResetFlag(User user) throws UpdateException {
    LdapConnection ld = null;
    String userDn = getDn(user.getUserId(), user.getContextId());
    try {
        List<Modification> mods = new ArrayList<Modification>();
        mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, OPENLDAP_PW_RESET));
        ld = getAdminConnection();
        modify(ld, userDn, mods, user);
    } catch (LdapNoSuchAttributeException e) {
        // Log, but don't throw, if reset attribute not present on account.
        LOG.info("deleteResetFlag user [" + user.getUserId() + "] no such attribute:" + OPENLDAP_PW_RESET);
    } catch (LdapException e) {
        String warning = "deleteResetFlag userId [" + user.getUserId() + "] caught LDAPException=" + e.getMessage();
        throw new UpdateException(GlobalErrIds.USER_PW_RESET_FAILED, warning, e);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) ArrayList(java.util.ArrayList) UpdateException(org.apache.directory.fortress.core.UpdateException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 12 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-fortress-core by apache.

the class PermDAO method revoke.

/**
 * @param pOp
 * @param user
 * @throws org.apache.directory.fortress.core.UpdateException
 *
 * @throws org.apache.directory.fortress.core.FinderException
 */
void revoke(Permission pOp, User user) throws UpdateException, FinderException {
    LdapConnection ld = null;
    String dn = getDn(pOp, pOp.getContextId());
    try {
        List<Modification> mods = new ArrayList<Modification>();
        mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, USERS, user.getUserId()));
        ld = getAdminConnection();
        modify(ld, dn, mods, pOp);
    } catch (LdapNoSuchAttributeException e) {
        String warning = "revoke perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] userId [" + user.getUserId() + "] assignment does not exist.";
        throw new FinderException(GlobalErrIds.PERM_USER_NOT_EXIST, warning);
    } catch (LdapException e) {
        String error = "revoke perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] userId [" + user.getUserId() + "] caught LdapException=" + e.getMessage();
        throw new UpdateException(GlobalErrIds.PERM_REVOKE_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) FinderException(org.apache.directory.fortress.core.FinderException) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) ArrayList(java.util.ArrayList) UpdateException(org.apache.directory.fortress.core.UpdateException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Aggregations

LdapNoSuchAttributeException (org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)12 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)11 ArrayList (java.util.ArrayList)4 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)4 Modification (org.apache.directory.api.ldap.model.entry.Modification)4 UpdateException (org.apache.directory.fortress.core.UpdateException)4 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)4 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)3 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)3 AuthenticationException (javax.naming.AuthenticationException)1 AuthenticationNotSupportedException (javax.naming.AuthenticationNotSupportedException)1 CommunicationException (javax.naming.CommunicationException)1 ContextNotEmptyException (javax.naming.ContextNotEmptyException)1 InvalidNameException (javax.naming.InvalidNameException)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 NameNotFoundException (javax.naming.NameNotFoundException)1 NamingException (javax.naming.NamingException)1 NoPermissionException (javax.naming.NoPermissionException)1 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1 ServiceUnavailableException (javax.naming.ServiceUnavailableException)1