Search in sources :

Example 11 with LdapConnection

use of com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection in project OpenUnison by TremoloSecurity.

the class ADProvider method deleteGroup.

@Override
public void deleteGroup(String name, User user, Map<String, Object> request) throws ProvisioningException {
    int approvalID = 0;
    if (request.containsKey("APPROVAL_ID")) {
        approvalID = (Integer) request.get("APPROVAL_ID");
    }
    Workflow workflow = (Workflow) request.get("WORKFLOW");
    try {
        LdapConnection con;
        try {
            con = this.ldapPool.getConnection();
        } catch (Exception e) {
            throw new ProvisioningException("Could not get LDAP connection " + user.getUserID(), e);
        }
        try {
            LDAPSearchResults res = con.getConnection().search(this.searchBase, 2, and(equal("objectClass", "group"), equal("cn", name)).toString(), new String[] { "1.1" }, false);
            if (res.hasMore()) {
                LDAPEntry entry = res.next();
                con.getConnection().delete(entry.getDN());
                this.cfgMgr.getProvisioningEngine().logAction(name, false, ActionType.Delete, approvalID, workflow, "domain-group", name);
            }
        } finally {
            con.returnCon();
        }
    } catch (Exception e) {
        throw new ProvisioningException("Could not set user's password", e);
    }
}
Also used : LDAPEntry(com.novell.ldap.LDAPEntry) LDAPSearchResults(com.novell.ldap.LDAPSearchResults) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) Workflow(com.tremolosecurity.provisioning.core.Workflow) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Example 12 with LdapConnection

use of com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection in project OpenUnison by TremoloSecurity.

the class ADProvider method setUserPassword.

@Override
public void setUserPassword(User user, Map<String, Object> request) throws ProvisioningException {
    StringBuffer filter = new StringBuffer();
    filter.append("(").append(this.userIDAttribute).append("=").append(user.getUserID()).append(")");
    try {
        LdapConnection con;
        try {
            con = this.ldapPool.getConnection();
        } catch (Exception e) {
            StringBuffer b = new StringBuffer();
            b.append("Could not get LDAP connection ").append(user.getUserID());
            throw new ProvisioningException(b.toString(), e);
        }
        try {
            doSetPassword(user, filter, con.getConnection(), request);
        } finally {
            con.returnCon();
        }
    } catch (Exception e) {
        throw new ProvisioningException("Could not set user's password", e);
    }
}
Also used : ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Example 13 with LdapConnection

use of com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection in project OpenUnison by TremoloSecurity.

the class LDAPProvider method syncUser.

@Override
public void syncUser(User user, boolean fromUserOnly, Set<String> attributes, Map<String, Object> request) throws ProvisioningException {
    try {
        StringBuffer filter = new StringBuffer();
        filter.append("(").append(this.userIDAttribute).append("=").append(user.getUserID()).append(")");
        LdapConnection con;
        try {
            con = this.ldapPool.getConnection();
        } catch (Exception e) {
            throw new ProvisioningException("Could not get LDAP connection " + user.getUserID(), e);
        }
        try {
            doSync(user, fromUserOnly, attributes, filter, con.getConnection(), request);
        } finally {
            con.returnCon();
        }
    } catch (LDAPException e) {
        throw new ProvisioningException("Could not sync user " + user.getUserID(), e);
    }
}
Also used : LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Aggregations

LDAPException (com.novell.ldap.LDAPException)13 LDAPReferralException (com.novell.ldap.LDAPReferralException)13 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)13 LdapConnection (com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)13 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 LDAPSearchResults (com.novell.ldap.LDAPSearchResults)5 LDAPEntry (com.novell.ldap.LDAPEntry)4 Workflow (com.tremolosecurity.provisioning.core.Workflow)4 LDAPAttribute (com.novell.ldap.LDAPAttribute)3 LDAPAttributeSet (com.novell.ldap.LDAPAttributeSet)1 LDAPModification (com.novell.ldap.LDAPModification)1 Attribute (com.tremolosecurity.saml.Attribute)1