LDAP with diacritics

Issue #256 resolved
Frantisek Troster created an issue


when I tried LDAP authentication I bumped into a problem when user was successfuly authenticated and ready to be saved into the database. In file model/user.py there is a line where ldap_dn is saved into the database and if this value contained diacritics it threw an error when performing SQL insert:

//You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.//

As I don't know anything about Python I changed the line:

{{{ #!python

new_user.ldap_dn = user_dn // to new_user.ldap_dn = unicode(user_dn, "utf-8", "ignore")


which I'm sure is not a solution, but it solved my problem. Could you please let me know whether there is a configuration that should be set to avoid issues with diacritics? Thank you

Comments (3)

  1. Marcin Kuzminski repo owner
    • changed status to open

    Hi, actually your solution is very good we have a special safe_unicode() method for this but the general idea is the same, in past we already had problems with non ascii chars from ldap and used safe_unicde, but i think we didn't do it on user_dn attr, so I'll patch the code as proposed. Thanks !

  2. Log in to comment