changeset 1289:f56533aa1caa beta

Automated merge with https://rhodecode.org/rhodecode
author "Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
date Tue, 26 Apr 2011 14:03:00 +0200
parents d6524f3025e8 (current diff) a781d315191c (diff)
children 74685a31cc43
files
diffstat 2 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/auth.py	Sun Apr 24 23:20:58 2011 +0200
+++ b/rhodecode/lib/auth.py	Tue Apr 26 14:03:00 2011 +0200
@@ -205,12 +205,12 @@
                 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,
--- a/rhodecode/lib/auth_ldap.py	Sun Apr 24 23:20:58 2011 +0200
+++ b/rhodecode/lib/auth_ldap.py	Tue Apr 26 14:03:00 2011 +0200
@@ -105,9 +105,10 @@
             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: