2012-12-05 90 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>