【问题标题】:Tomcat - OpenLDAP authenticationTomcat - OpenLDAP 身份验证
【发布时间】:2021-10-09 16:21:53
【问题描述】:

Tomcat 8 server.xml 中使用 OpenLDAP 进行身份验证所需的领域配置是什么?

<-- Active Directory, Working Fine-->
<Realm adCompat="true" alternateURL="ldap://a.b.c.d:3268"
      className="org.apache.catalina.realm.JNDIRealm" commonRole="CommonRole"
      connectionName="CN=admin,DC=test,DC=com"
      connectionPassword="test_password" connectionURL="ldap://a.b.c.d:3268"
      userBase="DC=test,DC=com" userRoleName="displayName"
      userSearch="(&amp;(objectCategory=user)(sAMAccountName={0}))"
      userSubtree="true" />

<!-- OpenLDAP, Not Working -->
<Realm alternateURL="ldap://a.b.c.d:4689"
      className="org.apache.catalina.realm.JNDIRealm" commonRole="CommonRole"
      connectionName="cn=admin,dc=test,dc=com"
      connectionPassword="test_password" connectionURL="ldap://a.b.c.d:4689"
      userBase="dc=test,dc=com" userRoleName="displayName"
      userSearch="(&amp;(objectClass=person)(cn={1}))"
      userSubtree="true" />
  
  

【问题讨论】:

  • 你检查official documentation了吗? connectionURL 是唯一需要的属性(当然除了className)。
  • userSearch 属性使用{0} 占位符作为用户名,您使用的是{1}
  • “不工作”不是问题描述。离题。

标签: tomcat openldap server.xml


【解决方案1】:
I have modified as mentioned by Piotr P. Karwasz and it worked. Thanks a lot!
The userSearch attribute uses a {0} placeholder for the username, you used {1}.
  
  <Realm alternateURL="ldap://a.b.c.d:4689"
                 className="org.apache.catalina.realm.JNDIRealm" commonRole="CommonRole"
                 connectionName="cn=admin,dc=test,dc=com"
                 connectionPassword="admin_pass" connectionURL="ldap://a.b.c.d:4689"
                 debug="9" userBase="dc=test,dc=com" userRoleName="displayName"
                 userSearch="(&amp;(objectClass=person)(cn={0}))"
                 userSubtree="true" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-15
    • 2011-12-25
    • 2012-06-27
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多