Changeset - 22eca93bea97
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2010-11-29 13:55:47
marcin@python-works.com
fixes a bug with two-pass ldap auth (thanks for TK Soh for that)
1 file changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/auth_ldap.py
Show inline comments
 
@@ -73,26 +73,25 @@ class AuthLdap(object):
 
        if "," in username:
 
            raise LdapUsernameError("invalid character in username: ,")
 
        try:
 
            ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, '/etc/openldap/cacerts')
 
            ldap.set_option(ldap.OPT_NETWORK_TIMEOUT, 10)
 
            server = ldap.initialize(self.LDAP_SERVER)
 
            if self.ldap_version == 2:
 
                server.protocol = ldap.VERSION2
 
            else:
 
                server.protocol = ldap.VERSION3
 

	
 
            if self.LDAP_BIND_DN and self.LDAP_BIND_PASS:
 
                login_dn = self.BASE_DN % {'user':uid}
 
                server.simple_bind_s(login_dn, self.LDAP_BIND_PASS)
 
                server.simple_bind_s(self.LDAP_BIND_DN, self.LDAP_BIND_PASS)
 

	
 
            dn = self.BASE_DN % {'user':uid}
 
            log.debug("Authenticating %r at %s", dn, self.LDAP_SERVER)
 
            server.simple_bind_s(dn, password)
 

	
 
            properties = server.search_s(dn, ldap.SCOPE_SUBTREE)
 
            if not properties:
 
                raise ldap.NO_SUCH_OBJECT()
 
        except ldap.NO_SUCH_OBJECT, e:
 
            log.debug("LDAP says no such user '%s' (%s)", uid, username)
 
            raise LdapUsernameError()
 
        except ldap.INVALID_CREDENTIALS, e:
0 comments (0 inline, 0 general)