Search in sources :

Example 36 with IdentityRef

use of org.olat.basesecurity.IdentityRef in project openolat by klemens.

the class LDAPLoginManagerImpl method getLDAPUser.

private LDAPUser getLDAPUser(LdapContext ctx, String member, Map<String, LDAPUser> dnToIdentityKeyMap, LDAPError errors) {
    LDAPUser ldapUser = dnToIdentityKeyMap.get(member);
    IdentityRef identity = ldapUser == null ? null : ldapUser.getCachedIdentity();
    if (identity == null) {
        String userFilter = syncConfiguration.getLdapUserFilter();
        String userDN = member;
        LDAPUserVisitor visitor = new LDAPUserVisitor(syncConfiguration);
        ldapDao.search(visitor, userDN, userFilter, syncConfiguration.getUserAttributes(), ctx);
        List<LDAPUser> ldapUserList = visitor.getLdapUserList();
        if (ldapUserList.size() == 1) {
            ldapUser = ldapUserList.get(0);
            Attributes userAttrs = ldapUser.getAttributes();
            identity = findIdentityByLdapAuthentication(userAttrs, errors);
            if (identity != null) {
                dnToIdentityKeyMap.put(userDN, ldapUser);
            }
        }
    }
    return ldapUser;
}
Also used : IdentityRef(org.olat.basesecurity.IdentityRef) Attributes(javax.naming.directory.Attributes) LDAPUser(org.olat.ldap.model.LDAPUser)

Aggregations

IdentityRef (org.olat.basesecurity.IdentityRef)36 ArrayList (java.util.ArrayList)18 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)18 Identity (org.olat.core.id.Identity)8 BusinessGroupRef (org.olat.group.BusinessGroupRef)8 LDAPUser (org.olat.ldap.model.LDAPUser)8 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)6 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)6 OLATResource (org.olat.resource.OLATResource)6 HashMap (java.util.HashMap)4 AuthenticationException (javax.naming.AuthenticationException)4 NamingException (javax.naming.NamingException)4 Attributes (javax.naming.directory.Attributes)4 GroupRoles (org.olat.basesecurity.GroupRoles)4 Roles (org.olat.core.id.Roles)4 BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)3 File (java.io.File)2