关于LDAP JNDI Tomcat:LDAP JNDI Tomcat – 可以连接但不能登录

LDAP JNDI Tomcat - can connect but not login

问题

我想将 tomcat-users.xml 数据(角色、用户名)移动到 LDAP。

我可以通过 JNDI 成功连接到 LDAP,但是我无法在 LDAP 中设置用户访问 Tomcat 的角色。
我正在关注这个,

http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html

并像他们一样设置 LDIF,但还没有成功。

环境:

  • 雄猫7
  • ApacheDS
  • 网豆

来源

这是我的 context.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/simple-service-webapp">

   <Realm className="org.apache.catalina.realm.JNDIRealm"
   debug="99"      
        connectionName="uid=admin,ou=system"
        connectionPassword="MYPASSWORD"
        connectionURL="ldap://localhost:10389"
          userBase="dc=mycompany,dc=com"
          userSearch="(cn={0})"
   userPassword="userPassword"
   userPattern="uid={0},ou=users,dc=mycompany,dc=com"
      roleBase="ou=groups,dc=mycompany,dc=com"
      roleName="cn"
      roleSearch="(uniqueMember={0})"    

   />
   </Context>

这是我的 ldap 的图像:
ldap 配置


OP 写道:

I worked with the nice folks over at #apache-directory and got a working ldap configuration:

1
2
3
4
5
6
7
8
9
10
<Realm className="org.apache.catalina.realm.JNDIRealm"
         connectionURL="ldap://localhost:10389"
         connectionName="uid=admin,ou=system"
         connectionPassword="ThisIsMyPasswordToConnect"
         userBase="ou=people,dc=mycompany,dc=com"
         userSearch="(uid={0})"
         userRoleName="memberOf"
         roleBase="ou=groups,dc=mycompany,dc=com"
         roleName="cn"
         roleSearch="(uniqueMember={0})" />