我想要通过Active Directory验证想要访问特定资源的用户。我使用JSF 2.1和Glassfish 3.1.2。 我尝试this,this,this,但它对我不起作用。用户无法登录。始终将我重定向到错误页面。
<auth-realm name="ADREALM" classname="com.sun.enterprise.security.auth.realm.ldap.LDAPRealm">
<property name="directory" value="LDAP://WIN-AK5HJBX4R4G.my.com/"></property>
<property name="search-filter" value="(&(objectClass=user)(sAMAccountName=%s))"></property>
<property name="base-dn" value="DC=my,DC=com"></property>
<property name="group-search-filter" value="(&(objectClass=group)(member=%d))"></property>
<property name="jaas-context" value="ldapRealm"></property>
<property name="assign-groups" value="Domain Users"></property>
<property name="search-bind-dn" value="WIN-AK5HJBX4R4G.my.com\Administrator"></property>
<property name="search-bind-password" value="Qwerty123"></property>
</auth-realm>
WIN-AK5HJBX4R4G - 它是我的虚拟服务器的默认名称(可以是192.168.56.101,也可以只是localhost。因为webapp部署在此服务器上并不意味着如何命名,AD也在此服务器上)
我尝试了一些形式的search-bind-dn,例如:
WIN-AK5HJBX4R4G.my.com\Administrator <- it works for asp.net so I think it is good form , maybe I'm wrong?
Administrator@my.com
CN=Administrator,CN=Users,DC=my,DC=com
没什么工作的。用户仍然无法登录。
<login-config>
<auth-method>FORM</auth-method>
<realm-name>ADREALM</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Pages</web-resource-name>
<url-pattern>/faces/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>A Funky User</description>
<role-name>user</role-name>
</security-role>
<security-role-mapping>
<role-name>user</role-name>
<group-name>Domain Users</group-name>
</security-role-mapping>
我还将-Djava.naming.referral=follow
添加到JVM选项中。
答案 0 :(得分:1)
解决。
将属性java.naming.referral=follow
添加到domain.xml。