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