首页 > 解决方案 > 请检查 JNDI 领域配置

问题描述

我的 Tomcat Web 应用程序日志告诉我 user1 不在来自 AD 的指定映射 LDAP 角色/组中。我相信我的问题在于 JNDI 领域的定义。有人可以查看它,看看我哪里出错了,我也包含了来自 AD 的 DN 信息:

我的“user1”帐户 DN 是

DistinguishedName : CN=user1,OU=Users,OU=Lab,DC=example,DC=com

我在 web.xml 配置中指定的角色/组“用户”是

DistinguishedName : CN=Users,CN=Builtin,DC=example,DC=com

我的领域配置是

<Realm
className="org.apache.catalina.realm.JNDIRealm"
debug="99"
connectionURL="ldap://example.com:389"
authentication="simple"
referrals="follow"
connectionName="cn=administrator,cn=users,dc=example,dc=com"
connectionPassword="##########"
userSearch="(sAMAccountName={0})"
userBase="cn=users,dc=example,dc=com"
userSubtree="true"
userRoleName="memberOf"
roleSearch="(member={0})"
roleName="cn"
roleSubtree="true"
roleBase="cn=users,cn=builtin,dc=example,dc=com"/>

标签: javatomcatactive-directoryldapjndi

解决方案


修好了自己。这是正确的配置。

<Realm
 className="org.apache.catalina.realm.JNDIRealm"
 debug="99"
 connectionURL="ldap://example.com:3268"
 authentication="simple"
 referrals="follow"
 connectionName="cn=administrator,cn=users,dc=example,dc=com"
 connectionPassword="########"
 userSearch="(sAMAccountName={0})"
 userBase="dc=example,dc=com"
 userSubtree="true"
 userRoleName="memberOf"
 roleName="cn"
 roleSubtree="true"/>

推荐阅读