Search in sources :

Example 1 with LdapConnection

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

the class ADProvider method findUser.

@Override
public User findUser(String userID, Set<String> attributes, Map<String, Object> request) throws ProvisioningException {
    try {
        StringBuffer filter = new StringBuffer();
        filter.append("(").append(this.userIDAttribute).append("=").append(userID).append(")");
        LdapConnection con;
        try {
            con = this.ldapPool.getConnection();
        } catch (Exception e) {
            StringBuffer b = new StringBuffer();
            b.append("Could not get LDAP connection ").append(userID);
            throw new ProvisioningException(b.toString(), e);
        }
        try {
            return doFindUser(userID, attributes, filter, con.getConnection());
        } finally {
            con.returnCon();
        }
    } catch (LDAPException e) {
        StringBuffer b = new StringBuffer();
        b.append("Could not locate user ").append(userID);
        throw new ProvisioningException(b.toString(), 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) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Example 2 with LdapConnection

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

the class ADProvider method createUser.

@Override
public void createUser(User user, Set<String> attributes, Map<String, Object> request) throws ProvisioningException {
    String dn = this.getDN(user);
    LDAPAttributeSet attrs = new LDAPAttributeSet();
    attrs.add(new LDAPAttribute("objectClass", this.objectClass));
    Iterator<String> userAttrs = user.getAttribs().keySet().iterator();
    while (userAttrs.hasNext()) {
        String attrName = userAttrs.next();
        if (!attributes.contains(attrName)) {
            continue;
        } else if (attrName.equalsIgnoreCase("userAccountControl") && request.containsKey(ProvisioningUtil.SET_PASSWORD)) {
            // we need set this AFTER the password
            continue;
        }
        LDAPAttribute ldap = new LDAPAttribute(attrName);
        Attribute attr = user.getAttribs().get(attrName);
        Iterator<String> vals = attr.getValues().iterator();
        while (vals.hasNext()) {
            ldap.addValue(vals.next());
        }
        attrs.add(ldap);
    }
    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 {
        doCreate(user, dn, attrs, con.getConnection(), request);
    } finally {
        con.returnCon();
    }
}
Also used : LDAPAttribute(com.novell.ldap.LDAPAttribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) Attribute(com.tremolosecurity.saml.Attribute) LDAPAttributeSet(com.novell.ldap.LDAPAttributeSet) 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 3 with LdapConnection

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

the class ADProvider 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) {
            StringBuffer b = new StringBuffer();
            b.append("Could not get LDAP connection ").append(user.getUserID());
            throw new ProvisioningException(b.toString(), e);
        }
        try {
            doSync(user, fromUserOnly, attributes, filter, con.getConnection(), request);
        } finally {
            con.returnCon();
        }
    } catch (LDAPException e) {
        StringBuffer b = new StringBuffer();
        b.append("Could not sync user ").append(user.getUserID());
        throw new ProvisioningException(b.toString(), 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) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Example 4 with LdapConnection

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

the class LDAPProvider method deleteGroup.

@Override
public void deleteGroup(String name, User user, Map<String, Object> request) throws ProvisioningException {
    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", this.cfgMgr.getCfg().getGroupObjectClass()), equal("cn", name)).toString(), new String[] { "1.1" }, false);
            if (res.hasMore()) {
                LDAPEntry entry = res.next();
                con.getConnection().delete(entry.getDN());
            }
        } 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) LDAPException(com.novell.ldap.LDAPException) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) LDAPReferralException(com.novell.ldap.LDAPReferralException) LdapConnection(com.tremolosecurity.provisioning.util.ldap.pool.LdapConnection)

Example 5 with LdapConnection

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

the class LDAPProvider method findUser.

@Override
public User findUser(String userID, Set<String> attributes, Map<String, Object> request) throws ProvisioningException {
    try {
        StringBuffer filter = new StringBuffer();
        filter.append("(").append(this.userIDAttribute).append("=").append(userID).append(")");
        LdapConnection con;
        try {
            con = this.ldapPool.getConnection();
        } catch (Exception e) {
            throw new ProvisioningException("Could not get LDAP connection " + userID, e);
        }
        try {
            return doFindUser(userID, attributes, filter, con.getConnection());
        } finally {
            con.returnCon();
        }
    } catch (LDAPException e) {
        throw new ProvisioningException("Could locate user " + userID, 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