2012-12-05 92 views
0

如何允许AD中的所有用户登录到我的应用程序(强制他们登录)?不只是由组定义。Tomcat AD身份验证 - 允许所有AD用户

这是我的web.xml。

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>MyApplication</web-resource-name> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 

</security-constraint> 

<security-role> 
    <role-name>some-ad-role</role-name> 
</security-role> 
<security-role> 
    <role-name>another-ad-role</role-name> 
</security-role> 

<!-- Basic Authentication using a JNDIRealm --> 
<login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>Login</realm-name> 
</login-config> 

我还是想用request.isUserInRole使用AD组进行授权我的应用程序中(),但起初每个人都可以登录到应用程序,以便我能有自己的检查目的的用户名。

+0

可能dublicate:HTTP://stackoverflow.com/questions/3720343/ldap-authentication-via-web-xml-in-tomcat – Cratylus

+0

@Cratylus那些例子谈话包括使用限制登录到唯一定义的角色的在安全约束中......我的问题稍有不同 - 我需要允许所有用户,无论他们在哪个组,只要他们在AD中。 – user1277546

+0

我们在wiki上放置了[Tomcat And LDAP](http://ldapwiki.willeke.com/wiki/Tomcat%20And%20LDAP),它应该有所帮助。 – jwilleke

回答

0

所以我找不到任何文档,但我似乎已经通过为角色名称使用通配符来解决此问题。

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>MyApplication</web-resource-name> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 

    <auth-constraint> 
     <role-name>*</role-name> 
    </auth-constraint> 

</security-constraint> 

<security-role> 
    <role-name>some-ad-role</role-name> 
</security-role> 
<security-role> 
    <role-name>another-ad-role</role-name> 
</security-role> 
<security-role> 
    <role-name>*</role-name> 
</security-role>