我想使用LDAP来保护我的Tomcat服务器。
首先,我尝试针对在线LDAP测试服务器,其详细信息存在于http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/中。
我的tomcat服务器将所有请求从端口8080重定向到端口8433,然后询问用户名和密码,然后(当我输入正确的数据时)返回403错误页面。
有什么问题?
server.xml的相关部分:
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.JNDIRealm" debug="10"
connectionURL="ldap://ldap.forumsys.com:389"
alternateURL="ldaps://ldap.forumsys.com:636"
userBase="dc=example,dc=com"
userSearch="(uid={0})"
userSubtree="true"
userRoleName="l"
connectionName="cn=read-only-admin,dc=example,dc=com"
connectionPassword="password"
/>
</Realm>
web.xml的相关部分:
<welcome-file-list>
<welcome-file>main.html</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resource-name>Authenticated area</web-resource-name>
<url-pattern>/main.html</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>HEAD</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>tomcat</role-name>
<role-name>Admin</role-name>
<role-name>Authenticated</role-name>
<role-name>mathematicians</role-name>
<role-name>gauss</role-name>
<role-name>galieleo</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<description>
This logical role includes all authenticated users
</description>
<role-name>tomcat</role-name>
<role-name>site-users</role-name>
<role-name>Authenticated</role-name>
<role-name>mathematicians</role-name>
<role-name>gauss</role-name>
<role-name>galieleo</role-name>
</security-role>
</web-app>
tomcat-users.xml中的相关部分:
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="mathematicians"/>
<role rolename="site-users"/>
<role rolename="tomcat"/>
<user username="gauss" roles="site-users,user,tomcat" />
</tomcat-users>
我使用用户名&#34; gauss&#34;和密码&#34;密码&#34;
答案 0 :(得分:0)
什么是userRoleName =&#34; l&#34;这应该是l = LDAP中用户条目的locale属性,值必须是
中的一个gettimeofday
如果您希望任何经过身份验证的用户只需:
<role-name>tomcat</role-name>
<role-name>site-users</role-name>
<role-name>Authenticated</role-name>
<role-name>mathematicians</role-name>
<role-name>gauss</role-name>
<role-name>galieleo</role-name>