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
This commit is contained in:
Cédric Krier committed 2014-09-19 18:39:49 +02:00
1 parent cfb6ee01d5
commit 2f93feb20b
1 file changed
+3 -2
+3 -2
View File
@@ -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: