Merge lp:~dreis-pt/ocb-addons/7.0-bug1079476-dr into lp:ocb-addons

Proposed by Daniel Reis
Status: Work in progress
Proposed branch: lp:~dreis-pt/ocb-addons/7.0-bug1079476-dr
Merge into: lp:ocb-addons
Diff against target: 21 lines (+2/-2)
1 file modified
auth_ldap/users_ldap.py (+2/-2)
To merge this branch: bzr merge lp:~dreis-pt/ocb-addons/7.0-bug1079476-dr
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Needs Fixing
OpenERP Community Backports Pending
Review via email: mp+186394@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Reis (dreis-pt) wrote :

I need to add that I'm using this fix in production.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Daniel, thanks for looking into this!

What I read on the Internet about python-ldap and unicode confirms what Olivier Dony writes on the bug report [1]. Any input that is passed on to python-ldap should be encoded as utf-8 instead of the default Python unicode. I can confirm this simply by logging on using a user name with a unicode character. This gives basically the same error as the one from the bug report. I think it would be much appreciated if you completed the mission to cover all strings passed to the LDAP server.

Code nit in l.18: given that the 'conf' dictionary comes from a raw sql query, it could be that conf['ldap_password'] is None. The following is probably safer in that case

    (conf['ldap_password'] or '').encode("utf-8")

[1] https://bugs.launchpad.net/openobject-addons/+bug/1079476/comments/5

review: Needs Fixing
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Setting to work-in-progress after 5 weeks of no response. Can you backport your fix to openobject-addons when you are happy with it?

Revision history for this message
Daniel Reis (dreis-pt) wrote :

Yes, I'll get back to it as soon as I can; just been too busy lately.

Unmerged revisions

9511. By Daniel Reis

Fix bug 1079476

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'auth_ldap/users_ldap.py'
2--- auth_ldap/users_ldap.py 2013-08-12 10:29:50 +0000
3+++ auth_ldap/users_ldap.py 2013-09-18 16:29:47 +0000
4@@ -102,7 +102,7 @@
5 if results and len(results) == 1:
6 dn = results[0][0]
7 conn = self.connect(conf)
8- conn.simple_bind_s(dn, password)
9+ conn.simple_bind_s(dn, password.encode("utf-8"))
10 conn.unbind()
11 entry = results[0]
12 except ldap.INVALID_CREDENTIALS:
13@@ -138,7 +138,7 @@
14 try:
15 conn = self.connect(conf)
16 conn.simple_bind_s(conf['ldap_binddn'] or '',
17- conf['ldap_password'] or '')
18+ conf['ldap_password'].encode("utf-8") or '')
19 results = conn.search_st(conf['ldap_base'], ldap.SCOPE_SUBTREE,
20 filter, retrieve_attributes, timeout=60)
21 conn.unbind()