我想authentication和授权一个LDAP组的所有用户(Windows上的ApacheDS 2.0.0-20,使用组中的多个uniqueMember属性和httpdconfiguration中的“Require ldap-group”语句)来访问Web资源。
尝试进行身份validation的用户也是此LDAP组的一部分,如果我在httpdconfiguration中使用“Require valid-user”语句而不是“Require ldap-group”,则授权用户。
build立:
ApacheDS LDAP中的组configuration:

httpd的configuration摘录:
<AuthnProviderAlias ldap ldapconfig> LDAPReferrals Off AuthLDAPBindDN "cn=query,ou=users,o=WJWext" AuthLDAPBindPassword secretpassword AuthLDAPURL "ldap://ldap.hostname:10389/o=WJWext?uid?sub" </AuthnProviderAlias> ... LogLevel trace7 <Location /xy> ... AuthType Basic AuthName "xy" AuthBasicProvider ldapconfig AuthLDAPGroupAttributeIsDN on AuthLDAPGroupAttribute uniqueMember AuthLDAPMaxSubGroupDepth 0 AuthLDAPSubGroupClass groupOfUniqueNames Require ldap-group cn=groupname,ou=groups,o=WJWext ... </Location>
httpd的日志文件显示用户可以被authentication但是不被组授权:
[Tue Nov 08 21:44:23.601378 2016] [authz_core:debug] [pid 15148] mod_authz_core.c(809): [client abcd:59427] AH01626: authorization result of Require ldap-group cn=groupname,ou=groups,o=WJWext) [Tue Nov 08 21:44:23.601415 2016] [authz_core:debug] [pid 15148] mod_authz_core.c(809): [client abcd:59427] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet) [Tue Nov 08 21:44:23.601547 2016] [authnz_ldap:debug] [pid 15148] mod_authnz_ldap.c(516): [client abcd:59427] AH01691: auth_ldap authenticate: using URL ldap://ldap.hostname:10389/o=WJWext?uid?sub [Tue Nov 08 21:44:23.601590 2016] [authnz_ldap:trace1] [pid 15148] mod_authnz_ldap.c(537): [client abcd:59427] auth_ldap authenticate: final authn filter is (&(objectclass=*)(uid=hudson)) [Tue Nov 08 21:44:23.615090 2016] [ldap:trace5] [pid 15148] util_ldap.c(1843): [client abcd:59427] LDC 55e4b4a94070 used for authn, must be rebound [Tue Nov 08 21:44:23.615236 2016] [authnz_ldap:debug] [pid 15148] mod_authnz_ldap.c(613): [client abcd:59427] AH01697: auth_ldap authenticate: accepting hudson [Tue Nov 08 21:44:23.615410 2016] [authz_core:debug] [pid 15148] mod_authz_core.c(809): [client abcd:59427] AH01626: authorization result of Require ldap-group cn=groupname,ou=groups,o=WJWext:denied
有点令人惊讶的是:在日志文件中,查看networkingstream量跟踪,似乎没有收集用户组成员资格的search请求。
有什么想法我们做错了吗?
为了回答赏金评论/请求,以下是使用AD身份validation并需要组成员资格的最低Apacheconfiguration,在使用mod_authnz_ldap的RHEL 7.x上进行testing:
<Directory "/some/path/"> AuthType Basic AuthName "Top Secret" AuthBasicProvider ldap AuthLDAPURL "ldaps://example.com/dc=EXAMPLE,dc=COM?sAMAccountname" AuthLDAPBindDN "CN=apache,OU=Accounts,DC=example,DC=com" AuthLDAPBindPassword "password" AuthLDAPMaxSubGroupDepth 0 AuthLDAPSubGroupAttribute member AuthLDAPSubGroupClass group Require ldap-group CN=example,OU=Groups,DC=example,DC=com </Directory>
调整AuthLDAPMaxSubGroupDepth允许我使用具有嵌套成员资格的组,但是当设置为0时,需要我的用户成为必要组的直接成员。
除了OP发布的日志之外,我看到这个而不是失败:
AH01697: auth_ldap authenticate: accepting user AH01713: auth_ldap authorize: require group: testing for group membership in "CN=example,OU=Groups,DC=example,DC=com" AH01714: auth_ldap authorize: require group: testing for member: CN=User Name,OU=Accounts,DC=example,DC=com (CN=example,OU=Groups,DC=example,DC=com) AH01715: auth_ldap authorize: require group: authorization successful (attribute member) [Comparison true (cached)][6 - Compare True] AH01626: authorization result of Require ldap-group CN=example,OU=Groups,DC=example,DC=com: granted AH01626: authorization result of <RequireAny>: granted
编辑:我设法重现使用提供者别名语法的问题,我相信OP是缺less一个<AuthzProviderAlias ...>块。 我rejigged我的例子configuration看起来像这样:
<AuthnProviderAlias ldap myldap> AuthLDAPURL "ldaps://example.com/dc=EXAMPLE,dc=COM?sAMAccountname" AuthLDAPBindDN "CN=apache,OU=Accounts,DC=example,DC=com" AuthLDAPBindPassword "password" </AuthnProviderAlias> <AuthzProviderAlias ldap-group ldap-group-alias "CN=example,OU=Groups,DC=example,DC=com"> AuthLDAPURL "ldaps://example.com/dc=EXAMPLE,dc=COM" AuthLDAPBindDN "CN=apache,OU=Accounts,DC=example,DC=com" AuthLDAPBindPassword "password" AuthLDAPMaxSubGroupDepth 0 AuthLDAPSubGroupAttribute member AuthLDAPSubGroupClass group </AuthzProviderAlias> <Directory "/some/path/"> AuthType Basic AuthName "Top Secret" AuthBasicProvider myldap Require ldap-group-alias </Directory>
这也可以,但是你最终会复制这个URL,绑定DN和密码。