Changeset - f56533aa1caa
[Not reviewed]
Merge beta
0 2 0
"Lorenzo M. Catucci" - 15 years ago 2011-04-26 14:03:00
lorenzo@sancho.ccd.uniroma2.it
Automated merge with https://rhodecode.org/rhodecode
2 files changed with 8 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/auth.py
Show inline comments
 
@@ -202,18 +202,18 @@ def authenticate(username, password):
 
                aldap = AuthLdap(**kwargs)
 
                (user_dn, ldap_attrs) = aldap.authenticate_ldap(username,
 
                                                                password)
 
                log.debug('Got ldap DN response %s', user_dn)
 

	
 
                user_attrs = {
 
                    'name': ldap_attrs[ldap_settings\
 
                                       .get('ldap_attr_firstname')][0],
 
                    'lastname': ldap_attrs[ldap_settings\
 
                                           .get('ldap_attr_lastname')][0],
 
                    'email': ldap_attrs[ldap_settings\
 
                                        .get('ldap_attr_email')][0],
 
                    'name': ldap_attrs.get(ldap_settings\
 
                                       .get('ldap_attr_firstname'), [''])[0],
 
                    'lastname': ldap_attrs.get(ldap_settings\
 
                                           .get('ldap_attr_lastname'),[''])[0],
 
                    'email': ldap_attrs.get(ldap_settings\
 
                                        .get('ldap_attr_email'), [''])[0],
 
                    }
 

	
 
                if user_model.create_ldap(username, password, user_dn,
 
                                          user_attrs):
 
                    log.info('created new ldap user %s', username)
 

	
rhodecode/lib/auth_ldap.py
Show inline comments
 
@@ -102,15 +102,16 @@ class AuthLdap(object):
 
            lobjects = server.search_ext_s(self.BASE_DN, self.SEARCH_SCOPE,
 
                                           filt)
 

	
 
            if not lobjects:
 
                raise ldap.NO_SUCH_OBJECT()
 

	
 
            for (dn, attrs) in lobjects:
 
            for (dn, _attrs) in lobjects:
 
                try:
 
                    server.simple_bind_s(dn, password)
 
                    attrs = server.search_ext_s(dn, ldap.SCOPE_BASE, '(objectClass=*)')[0][1]
 
                    break
 

	
 
                except ldap.INVALID_CREDENTIALS, e:
 
                    log.debug("LDAP rejected password for user '%s' (%s): %s",
 
                              uid, username, dn)
 

	
0 comments (0 inline, 0 general)