[python-ldap] § in passwords
Andreas Stenius
andreas.stenius at astekk.se
Thu Sep 29 09:42:49 EDT 2016
Hi,
I seem to have run into a bug in python-ldap. I have a user who
consistently fail to login, but for "everyone" else it works just fine.
After some troubleshooting, I became aware of his password containing a
§-sign. I've done some testing locally, and have verified using wireshark,
that when I try to bind a user with a password containing a §, there is no
activity for that bind on the network at all.
I have the following python code:
```
obj = ldap.initialize (cfg['url'])
obj.bind_s (cfg['bind_dn'], cfg['bind_password'],
ldap.AUTH_SIMPLE)
search_filter = cfg['search_filter'].format (username =
username)
groups = cfg['groups_attr']
users = obj.search_s (
cfg['base_dn'], ldap.SCOPE_SUBTREE,
search_filter, [groups])
if len (users) < 1:
break
obj.bind_s (users[0][0], password, ldap.AUTH_SIMPLE)
```
If the test cases are standalone in some way, I could look into writing a
test for this, with some helpful pointers into where/how that works..
I have attached a redacted screenshot of the wireshark capture, logging two
login attempts (both with wrong passwords), the first using "foobar" as
password, and the second using "foo§bar".
The screenshot is from using python-ldap version 2.4.25, but I see the same
behaviour on 2.4.27 as well.
----
And, just after posting this (re-posted, thanks for the moderation blocker
:p), I realized I was masking the exception raised, which provided a good
indication to the problem at hand..
Here's the bottom of the traceback:
obj.bind_s (users[0][0], password, ldap.AUTH_SIMPLE)
File
"/Users/aadt/.virtualenvs/ssoauth/lib/python2.7/site-packages/ldap/ldapobject.py",
line 237, in bind_s
msgid = self.bind(who,cred,method)
File
"/Users/aadt/.virtualenvs/ssoauth/lib/python2.7/site-packages/ldap/ldapobject.py",
line 231, in bind
return self.simple_bind(who,cred)
File
"/Users/aadt/.virtualenvs/ssoauth/lib/python2.7/site-packages/ldap/ldapobject.py",
line 216, in simple_bind
return
self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
File
"/Users/aadt/.virtualenvs/ssoauth/lib/python2.7/site-packages/ldap/ldapobject.py",
line 106, in _ldap_call
result = func(*args,**kwargs)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa7' in
position 5: ordinal not in range(128)
[image: ldap-wireshark-capture.png]Cheers,
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160929/f11e4c2f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldap-wireshark-capture.png
Type: image/png
Size: 251395 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160929/f11e4c2f/attachment-0001.png>
More information about the python-ldap
mailing list