Marc Brevoort wrote: > I've inherited a little authentication module which uses > python-ldap (v1.92, 2005/11/03). For the most of it, it works > fine, but when a user has decided to use non-ascii characters > in their password, they will be blocked access and the > authentication log shows a message such as: > > 2010-08-27 11:02:50,398 DEBUG Exception: 'ascii' codec can't encode > character u'\xdf' in position 5: ordinal not in range(128)
I'm not sure which component write this message. But python-ldap expects all values to be raw strings. So the calling application is responsible for converting Unicode objects to raw strings with the appropriate encoding. In case of LDAPv3 this is UTF-8. > - It should be possible to work around the issue by escaping the > non-ascii characters in the password, replacing them with a backslash Please try to understand first how the Python syntax representation of Unicode and raw strings is which displayed in the message above. http://docs.python.org/reference/lexical_analysis.html#string-literals There's no need to mess with the back-slashes at all. Simply fix the calling application to do the right thing. Probably calling password.encode('utf-8') will do. Ciao, Michael. ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Python-LDAP-dev mailing list Python-LDAP-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/python-ldap-dev