tomcat - 设置 Tomcat 以使用来自特定组的 LDAP 用户

标签 tomcat authentication ldap

我正在设置 Tomcat 8.5 服务器以对 Tomcat 的管理器部分使用 LDAP 身份验证。到目前为止,我已使用正确的领域设置更改了 server.xml。

<Realm className="org.apache.catalina.realm.JNDIRealm" 
                 debug="99"
                 connectionURL="ldap://ldap.server.com:389"
                 authentication="simple"
                 referrals="follow"
                 connectionName="CN=user,OU=Service,OU=Users,DC=server,DC=group,DC=mainserver,DC=com"
                 connectionPassword="password of the user"
                 userSearch="(sAMAccountName={0})"
                 userBase="DC=group,DC=mainserver,DC=com" 
                 userSubtree="true"
                 roleSearch="(member={0})" 
                 roleName="name of the ldap role" 
                 roleSubtree="true"
                 roleBase="OU=Groups,DC=group,DC=mainserver,DC=com"/>

现在我想使用 LDAP 组来授予用户访问 tomcat 管理器/状态页面的权限。我怎样才能做到这一点?我尝试将管理器的 web.xml 更改为

 <security-role>
    <description>
      The role that is required to access the HTML Manager pages
    </description>
    <role-name>LDAP group</role-name>
  </security-role>
  <security-role>
    <description>
      The role that is required to access the text Manager pages
    </description>
    <role-name>LDAP group</role-name>
  </security-role>
  <security-role>
    <description>
      The role that is required to access the HTML JMX Proxy
    </description>
    <role-name>LDAP group</role-name>
  </security-role>
  <security-role>
    <description>
      The role that is required to access to the Manager Status pages
    </description>
    <role-name>LDAP group</role-name>
  </security-role>

但是没有用。现在可以使用用户登录,但是当我浏览到管理器页面时出现“403 访问被拒绝”错误。在 Tomcat 的日志文件中也没有任何错误。

最佳答案

将 roleName 更改为 LDAP 中的正确角色名称值,并且在重新启动 tomcat 服务后它工作得很好。

关于tomcat - 设置 Tomcat 以使用来自特定组的 LDAP 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40083432/

相关文章:

java - 找不到配置 xml 文件 - spring intellij

azure - 正在使用 AzureAD 中的所有可用范围生成 token

javascript - Passport 认证唯一 session ID概念

ios - 无缝处理客户端应用程序中的授权 token 过期

.net - 如何检查 ldap 连接是否安全?

java - 为每个 webapp 设置 Tomcat 7 工作目录?

apache - 如何使用 JBoss(或 Apache Tomcat)将 ip 和端口绑定(bind)到子域

java: ldap 命名异常

java - spring boot war部署到tomcat给出404错误

python - 使用 ldap python 启用 Active Directory 用户帐户