2010-05-11 76 views
0

我有一个在Netbeans的(6.8)开发和(6)使用LDAP(活动目录)在Tomcat中工作正常,一个简单的web应用程序。从Tomcat转换LDAP到GlassFish

我需要将其转换为EE(JSF2),所以我正在从Tomcat移动到GlassFish(v3)。

我已经改变了网页文件,XHTML和配置的XML文件。但是,我无法获取GlassFish LDAP配置进行身份验证。

我附加了旧的web.xml和server.xml(来自Tomcat)片段以及新的web.xml,sun-web.xml和GlassFish配置的各个部分。

如果有人可以帮我找出我在哪里丢失了一块将允许用户进行身份验证,我将不胜感激。 (顺便说一下,我不使用角色,只是对LDAP数据库进行身份验证已经足够了。)

现在,我的应用程序会提示我输入用户,当我尝试访问'受保护的文件'区域,GlassFish服务器在未通过身份验证时会引发异常。因为它在Tomcat下工作,所以我知道我有正确的信息,我只是不知道如何格式化它以让GlassFish传递它。

谢谢。

TOMCAT FILES: - 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> 
    

    *

    BASIC 请输入您的用户名和密码:

GLASSFISH FILES: (我启用了安全性面板上的安全管理器,默认领域设置'LDAPRealm',并添加了“-Djava.naming.referral = follow”JVM选项。) - domain.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="(&amp;(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> 
  • 太阳网。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) 
+0

不是真的有关NB的问题... – vkraemer 2010-05-11 14:54:26

+0

我很困惑你的评论。我没有把它标记为NB问题,我只提到我使用NB作为IDE。 我通过你的个人资料看到你对gf有一定的了解。你能提供任何有关我在这里失踪的信息吗?谢谢。 – Jon 2010-05-12 11:44:12

回答

0

好了,我已经解决了这个问题。 Glassfish似乎没有像Tomcat那样对群体宽容。使用*作为组名不适合我。

  • domain.xml中,我加入这一行:
<property name="assign-groups" value="Domain Users" /> 

- “域用户” 是在Active Directory中的组,每个人都被投入时,他们的帐户创建。 (此应用只需要验证一个人是AD内,则使用内部安全应用程式内的访问。)

  • 在web.xml,该AUTH-约束必须被添加到“安全约束上” :
<auth-constraint> 
    <description/> 
    <role-name>users</role-name> 
</auth-constraint> 

- “用户” 在sun-web.xml中引用,但不能在我的应用程序。

  • sun-web.xml中,需要这种映射到 “用户” 和 “域用户” 链接:

& LT安全 - 角色 - 映射& GT

&lt role-name &gt users &lt /role-name &gt 
&lt group-name &gt Domain Users &lt /group-name &gt  

& lt/security-role-mapping & gt

- 显然,此消息编辑功能不能很好地处理引号或代码中的gt和lt字符。上面的代码应该有正确的符号。 (我想stackoverflow需要更好的测试...)

看来我缺少的关键组件是domain.xml中的“assign-groups”。

希望这可以帮助任何有此问题的人。