[FIX] auth_ldap login when password is unicode

python ldap library api is str based, assume utf-8 encoding for non-ascii
chars.

Closes #5376 lp:1079476
This commit is contained in:
Daniel Reis 2015-03-01 02:01:55 +01:00 committed by Antony Lesuisse
parent e5a94f74aa
commit ccf021938d
1 changed files with 2 additions and 2 deletions

View File

@ -105,7 +105,7 @@ class CompanyLDAP(osv.osv):
if results and len(results) == 1:
dn = results[0][0]
conn = self.connect(conf)
conn.simple_bind_s(dn, password)
conn.simple_bind_s(dn, password.encode('utf-8'))
conn.unbind()
entry = results[0]
except ldap.INVALID_CREDENTIALS:
@ -141,7 +141,7 @@ class CompanyLDAP(osv.osv):
try:
conn = self.connect(conf)
conn.simple_bind_s(conf['ldap_binddn'] or '',
conf['ldap_password'] or '')
conf['ldap_password'].encode('utf-8') or '')
results = conn.search_st(conf['ldap_base'], ldap.SCOPE_SUBTREE,
filter, retrieve_attributes, timeout=60)
conn.unbind()