From 22b8fa23c5fa9274ab7af95fdf778b034ce4e7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 16 Oct 2009 19:01:03 +0200 Subject: [PATCH] Set OPT_REFERRALS and filter search result for Active Directory --- res.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/res.py b/res.py index 2b50f51f18..5ec2ecfaac 100644 --- a/res.py +++ b/res.py @@ -39,8 +39,11 @@ class User(ModelSQL, ModelView): else: filter = '(%s=%s)' % (connection.auth_uid, login) - return con.search_s(connection.auth_base_dn or '', scope, + result = con.search_s(connection.auth_base_dn or '', scope, filter, attrs) + if connection.active_directory: + result = [x for x in result if x[0]] + return result def _check_passwd_ldap_user(self, cursor, user, logins, context=None): connection_obj = self.pool.get('ldap.connection') @@ -51,6 +54,8 @@ class User(ModelSQL, ModelView): find = False try: con = ldap.initialize(connection.uri) + if connection.active_directory: + con.set_option(ldap.OPT_REFERRALS, 0) if connection.secure == 'tls': con.start_tls_s() if connection.bind_dn: @@ -93,6 +98,8 @@ class User(ModelSQL, ModelView): context=context) try: con = ldap.initialize(connection.uri) + if connection.active_directory: + con.set_option(ldap.OPT_REFERRALS, 0) if connection.secure == 'tls': con.start_tls_s() if connection.bind_dn: @@ -121,6 +128,8 @@ class User(ModelSQL, ModelView): context=context) try: con = ldap.initialize(connection.uri) + if connection.active_directory: + con.set_option(ldap.OPT_REFERRALS, 0) if connection.secure == 'tls': con.start_tls_s() if connection.bind_dn: