From 2f93feb20bbf92a2f8338b58dcd3070c89f0a5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 19 Sep 2014 18:39:49 +0200 Subject: [PATCH] Enforce string usage with ldap The singleton could be a fake record and so it will return None for all fields. ldap requires string as parameters otherwise it raise a TypeError. issue4159 review12561002 --- res.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/res.py b/res.py index 654124a448..7bca8866c4 100644 --- a/res.py +++ b/res.py @@ -127,13 +127,14 @@ class User: LoginAttempt = pool.get('res.user.login.attempt') connection, = Connection.search([], limit=1) try: - con = ldap.initialize(connection.uri) + con = ldap.initialize(connection.uri or '') if connection.active_directory: con.set_option(ldap.OPT_REFERRALS, 0) if connection.secure == 'tls': con.start_tls_s() if connection.bind_dn: - con.simple_bind_s(connection.bind_dn, connection.bind_pass) + con.simple_bind_s(connection.bind_dn or '', + connection.bind_pass or '') users = cls.ldap_search_user(login, con, connection, attrs=[str(connection.auth_uid)]) if users and len(users) == 1: