#11531 closed defect (fixed)
Cannot authenticate with accented chars
Reported by: | anonymous | Owned by: | Nikolaos Papagrigoriou |
---|---|---|---|
Priority: | normal | Component: | TracLdapAuthPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description (last modified by )
If there is an accented char (like ò) in the login field, the authentication fails with the following error (see the last row):
Trac[store] DEBUG: LDAPAuth: Unexpected error: Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/ldapauth/store.py", line 69, in check_password bind_cn = self._search_user(conn, user) File "build/bdist.linux-x86_64/egg/ldapauth/store.py", line 129, in _search_user self.search_filter % user) File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 516, in search_s return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout) File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 509, in search_ext_s msgid = self.search_ext(base,scope,filterstr,attrlist,attrsonly,serverctrls,clientctrls,timeout,sizelimit) File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 505, in search_ext timeout,sizelimit, File "/usr/lib/python2.6/dist-packages/ldap/ldapobject.py", line 96, in _ldap_call result = func(*args,**kwargs) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf2' in position 39: ordinal not in range(128)
May be a solution could be to encode('utf-8')? http://stackoverflow.com/questions/1652904/unicodeencodeerror-ascii-codec-cant-encode-character
If this cannot be fixed in the TracLdapAuthPlugin code, what can be done to avoid this issue? Thanks
Attachments (0)
Change History (8)
comment:1 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
It will take some time to fix it because I do not control an LDAP server where I could create users with usernames containing non-ascii characters. I.e. I have no way to easily reproduce your issue.
The problem seems to be related to how python-ldap treats unicode characters. See
I could provide a fix but I have no way to test it. Sorry for that.
Could you avoid usernames with non-ascii characters or convert the accented characters to non accented ones? For example, in German the character "ü" is converted to "ue".
comment:4 Changed 11 years ago by
Thanks for your reply.
You could create a virtual machine (eg debian) with openLDAP eg: sudo apt-get update sudo apt-get install slapd sudo apt-get install ldap-utils
and use Apache Directory Studio client to add some users https://directory.apache.org/studio/downloads.html
In the meanwhile I try to avoid non ascii chars. Regards
comment:5 Changed 8 years ago by
This fix is simple, just tried it:
in checkpassword
add after the is_empty
check
if isinstance(password, unicode): password = password.encode("utf-8")
Wondering how long is it needed to fix this issue? days? weeks? months? years?