[ldapfeed] ldap3 do not raise an exception in case of failure of cnx.bind()
authorDavid Douard <david.douard@logilab.fr>
Wed, 25 May 2016 17:19:14 +0200
changeset 11263 9ae85b069325
parent 11262 25f9a76ddf50
child 11274 d0f6fe008ec4
[ldapfeed] ldap3 do not raise an exception in case of failure of cnx.bind() but return 'False' instead.
server/sources/ldapfeed.py
--- a/server/sources/ldapfeed.py	Wed May 25 17:43:53 2016 +0200
+++ b/server/sources/ldapfeed.py	Wed May 25 17:19:14 2016 +0200
@@ -284,26 +284,27 @@
         else:
             # user specified, we want to check user/password, no need to return
             # the connection which will be thrown out
-            self._authenticate(conn, user, userpwd)
+            if not self._authenticate(conn, user, userpwd):
+                raise AuthenticationError()
         return conn
 
     def _auth_simple(self, conn, user, userpwd):
         conn.authentication = ldap3.AUTH_SIMPLE
         conn.user = user['dn']
         conn.password = userpwd
-        conn.bind()
+        return conn.bind()
 
     def _auth_digest_md5(self, conn, user, userpwd):
         conn.authentication = ldap3.AUTH_SASL
         conn.sasl_mechanism = 'DIGEST-MD5'
         # realm, user, password, authz-id
         conn.sasl_credentials = (None, user['dn'], userpwd, None)
-        conn.bind()
+        return conn.bind()
 
     def _auth_gssapi(self, conn, user, userpwd):
         conn.authentication = ldap3.AUTH_SASL
         conn.sasl_mechanism = 'GSSAPI'
-        conn.bind()
+        return conn.bind()
 
     def _search(self, cnx, base, scope,
                 searchstr='(objectClass=*)', attrs=()):