Search code examples
authenticationtomcatactive-directorycharacter-encodingldap

Tomcat authentification with LDAP (against Active Directory) fails when the character EURO is used in a password


A user tries to connect to a tomcat application. Her password contains the € glyph. On other applications, it works just fine. On our in-house application, it fails.

We use a linux box, tomcat 8.5, jdk 1.8, with -Dfile.encoding=UTF-8, Basic auth with a JNDIrealm. The header Basic XXXXXX is good.

<Realm 
    className="org.apache.catalina.realm.JNDIRealm" 
    debug="99" 
    connectionURL="ldap://someurl:389" 
    connectionName="someName" 
    connectionPassword="somePassword" 
    referrals="follow" userBase="DC=EXAMPLE,DC=COM"
    userSearch="(sAMAccountName={0})" 
    userSubtree="true" 
    adCompat="true" />

What is wrong ?


Solution

  • Found it. You have to use a Valve with the encoding specified.

    <Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
          charset="UTF-8" />
    

    See https://cwiki.apache.org/confluence/display/TOMCAT/Character+Encoding#CharacterEncoding-Q10HowtoconfiguretheBASICauthenticationschemetouseUTF-8