【发布时间】:2011-02-18 03:16:48
【问题描述】:
我有一个简单的网络应用程序,它是在 Netbeans(6.8) 中开发的,并且使用 LDAP(Active Directory) 在 Tomcat(6) 中运行良好。
我需要将其转换为 EE (JSF2),因此我要从 Tomcat 迁移到 GlassFish(v3)。
我已将 web 文件更改为 xhtml 并配置了 xml 文件。但是,我无法让 GlassFish LDAP 配置进行身份验证。
我正在附加我的旧 web.xml 和 server.xml(来自 Tomcat)sn-ps 以及新 web.xml、sun-web.xml 和 GlassFish 配置的部分。
如果有人能帮助我找出我遗漏了允许用户通过身份验证的部分,我将不胜感激。 (顺便说一句,我没有使用角色,只是针对 LDAP 数据库进行身份验证就足够了。)
就像现在一样,当我尝试访问“受保护”区域中的文件时,我的应用程序会提示我输入用户,并且 GlassFish 服务器在验证失败时会引发异常。因为它在 Tomcat 下工作,所以我知道我有正确的信息,我只是不知道如何格式化它以让 GlassFish 传递它。
谢谢。
TOMCAT 文件: - Tomcat server.xml:
-
web.xml:
<web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <description>Authentication Required</description> <url-pattern>/faces/protected/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>*</role-name> </auth-constraint>*
基本的 请输入您的用户名和密码:
玻璃鱼文件: (我在安全面板上启用了安全管理器,将默认领域设置为“LDAPRealm”,并添加了“-Djava.naming.referral=follow”JVM 选项。) - 域.xml:
<auth-realm name="certificate" classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" />
<auth-realm classname="com.sun.enterprise.security.auth.realm.ldap.LDAPRealm" name="LdapRealm">
<property description="()" name="search-bind-password" value="xxxxxxxx" />
<property description="()" name="search-bind-dn" value="cn=xxxxxxxx,ou=Administrators,ou=Information Technology,ou=ITTS,ou=Administrative,ou=xxx,dc=xxxxxx,dc=xxx" />
<property name="jaas-context" value="ldapRealm" />
<property name="base-dn" value="ou=xxx,dc=xxxxxx,dc=xxx" />
<property name="directory" value="ldap://xxxx.xxxxxx.xxx:389" />
<property name="search-filter" value="(&(objectClass=user)(sAMAccountName=%s))" />
</auth-realm>
-web.xml:
<security-constraint>
<display-name>protected</display-name>
<web-resource-collection>
<web-resource-name>ProtectedArea</web-resource-name>
<description/>
<url-pattern>/faces/protected/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description/>
<role-name>*</role-name>
</security-role>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>LDAPRealm</realm-name>
<form-login-config>
<form-login-page>/faces/login.xhtml</form-login-page>
<form-error-page>/faces/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
-
sun-web.xml:
这是它抛出的异常:
SEVERE: SEC1113: Exception in LdapRealm when trying to authenticate user.
javax.security.auth.login.LoginException: javax.security.auth.login.LoginException: User yyyyyyy not found.
at com.sun.enterprise.security.auth.realm.ldap.LDAPRealm.findAndBind(LDAPRealm.java:450)
【问题讨论】:
-
不是关于 NB 的问题...
-
我对你的评论感到困惑。我没有将其标记为 NB 问题,我只提到我使用 NB 作为 IDE。我从您的个人资料中看到您对 gf 有所了解。您能否就我在这里缺少的内容提供任何见解?谢谢。