Glassfish 3.1 ldapRealm ActiveDirectory组成员资格

时间:2012-01-13 15:14:46

标签: ldap glassfish jaas active-directory-group

我正在尝试在Glassfish 3.1上实现ldapRealm。我可以使用以下配置正常登录,但是我无法正确获得AD的组成员身份。我跟着group memberships in (AD) ldap Realm加入了group-search-filter,但仍然无法正常工作 这是我的web.xml:

<auth-realm name="ADREALM" classname="com.sun.enterprise.security.auth.realm.ldap.LDAPRealm">
    <property name="directory" value="ldap://domain.com:389"></property>
    <property name="search-filter" value="(&amp;(objectCategory=user)(sAMAccountName=%s))"></property>
    <property name="search-bind-dn" value="admin@domain.com"></property>
    <property description="null" name="base-dn" value="OU=CORP Users,DC=domain,DC=com"></property>
    <property name="group-search-filter" value="(&amp;(objectCategory=group)(member=%d))"></property>
    <property name="search-bind-password" value="password"></property>
    <property name="jaas-context" value="ldapRealm"></property>
</auth-realm>

我还将以下选项添加到server-config&gt; JVM

-Djava.naming.referral=follow  

Glassfish的日志条目:

FINE: [Web-Security] hasUserDataPermission perm: (javax.security.jacc.WebUserDataPermission /j_security_check POST)
FINE: [Web-Security] hasUserDataPermission isGranted: true
FINEST: Processing login with credentials of type: class com.sun.enterprise.security.auth.login.common.PasswordCredential
FINE: Logging in user [kip] into realm: ADREALM using JAAS module: ldapRealm
FINE: Login module initialized: class com.sun.enterprise.security.auth.login.LDAPLoginModule
FINE: search: baseDN: OU=CORP Users,DC=domain,DC=com  filter: (&(objectCategory=user)(sAMAccountName=kip))
FINE: Found user DN: CN=Kipling,OU=IT,OU=CORP Users,DC=domain,DC=com
FINE: LDAP:Group search filter: (&(objectCategory=group)(member=CN=Kipling,OU=IT,OU=CORP Users,DC=domain,DC=com))
FINE: LDAP: Group memberships found: 
FINE: LDAP: login succeeded for: kip
FINE: JAAS login complete.
FINE: JAAS authentication committed.
FINE: Password login succeeded for : kip
FINE: Set security context as user: kip  

请注意,找到的组成员身份为空。如果需要更多信息,请告诉我。

2 个答案:

答案 0 :(得分:4)

周末,我发现我的ldapRealm配置出了什么问题。由于我将base-dn设置为用户ou分支,并且组信息位于不同的分支上,因此glassfish无法找到我的组dn。 (限制太多 - 也是SO提出的问题之一)。为了使group-search-filter起作用,我必须为ldapRealm添加额外的属性,group-base-dn用于组数据检索。

<property name="group-base-dn" value="OU=CORP Groups,DC=domain,DC=com"></property>

因此,除非我将base-dn设置为基本DC=domain,DC=com,否则我必须包含group-base-dn属性。这是我最后的ldapRealm配置:

<auth-realm name="ADREALM" classname="com.sun.enterprise.security.auth.realm.ldap.LDAPRealm">
    <property name="directory" value="ldap://domain.com:389"></property>
    <property name="jaas-context" value="ldapRealm"></property>
    <property name="base-dn" value="OU=CORP Users,DC=domain,DC=com" description="null"></property>
    <property name="search-filter" value="(&amp;(objectCategory=user)(sAMAccountName=%s))"></property>
    <property name="group-base-dn" value="OU=CORP Groups,DC=domain,DC=com"></property>
    <property name="group-search-filter" value="(&amp;(objectCategory=group)(member=%d))"></property>
    <property name="search-bind-dn" value="admin@domain.com"></property>
    <property name="search-bind-password" value="password"></property>
</auth-realm>  

我希望这可以帮助任何人配置ldapRealm。谢谢!

附加玻璃鱼日志:

FINE: search: baseDN: OU=CORP Users,DC=domain,DC=com  filter: (&(objectCategory=user)(sAMAccountName=kip))
FINE: Found user DN: CN=Kipling,OU=IT,OU=CORP Users,DC=domain,DC=com
FINE: LDAP:Group search filter: (&(objectCategory=group)(member=CN=Kipling,OU=IT,OU=CORP Users,DC=domain,DC=com))
FINE: LDAP: Group memberships found:  Application Administrators
FINE: LDAP: login succeeded for: kip
FINE: JAAS login complete.
FINE: JAAS authentication committed.

答案 1 :(得分:0)

objectClass=Group,而不是搜索过滤器中的objectCategory=group