在AuthLDAPURL中有多个searchfilter是否可行?
示例uidfilter:
<Location /test/> AuthType Basic AuthName "Test" AuthBasicProvider ldap AuthUserFile /dev/null AuthLDAPURL ldap://example.test.com/o=test,c=com?uid AuthLDAPBindDN "******" AuthLDAPBindPassword ****** require ldap-group cn=group01,o=test,c=com </Location>
我们需要searchuid或邮件。 喜欢…
AuthLDAPURL ldap://example.test.com/o=test,c=com?uid|mail
解决scheme (适用于我):
用Apache 2.4testinghttp://httpd.apache.org/docs/current/mod/mod_authn_core.html
<AuthnProviderAlias ldap ldap-uid> AuthLDAPBindDN "******" AuthLDAPBindPassword ****** AuthLDAPURL "ldap://example.test.com/o=test,c=com?uid??(&(isMemberOf=cn=group01,o=test,c=com))" </AuthnProviderAlias> <AuthnProviderAlias ldap ldap-mail> AuthLDAPBindDN "******" AuthLDAPBindPassword ****** AuthLDAPURL "ldap://example.test.com/o=test,c=com?mail??(&(isMemberOf=cn=group01,o=test,c=com))" </AuthnProviderAlias> <Location "/test/"> Order deny,allow Allow from all AuthType Basic AuthName "Login with mail or uid" AuthBasicProvider ldap-uid ldap-mail LDAPReferrals Off Require valid-user </Location>
Thx Tonin!
我想你的意思是寻找属性uid
或mail
(而不是过滤)。 虽然RFC 2255允许在LDAP URL中使用两个不同的属性,但这是不可能的。
Apache mod_authnz_ldap文档声明URL必须如下所示: ldap://host:port/basedn?attribute?scope?filter
with
但是,添加另一个apache模块,即mod_authn_alias ,可以使用2个不同的LDAPURL作为不同的身份validation提供程序。 为了达到这个目的,你可以添加一个新的文件(包含在你的apacheconfiguration的根目录下),其中包含:
# Different LDAP attributes to be used as login <AuthnProviderAlias ldap ldap-uid> AuthLDAPURL ldap://example.test.com/o=test,c=com?uid AuthLDAPBindDN "******" AuthLDAPBindPassword ****** </AuthnProviderAlias> <AuthnProviderAlias ldap ldap-mail> AuthLDAPURL ldap://example.test.com/o=test,c=com?mail AuthLDAPBindDN "******" AuthLDAPBindPassword ****** </AuthnProviderAlias>
然后,在您的<Location>
语句中,使用以下configuration:
<Location /test/> AuthType Basic AuthName "Test" AuthBasicProvider ldap-uid ldap-mail AuthUserFile /dev/null require ldap-group cn=group01,o=test,c=com </Location>
这将首先尝试使用uid
进行身份validation,如果失败,请尝试使用mail
属性。 使用这种types的configuration,您可以根据需要添加任意数量的LDAPURL提供程序。
但是,您必须注意一点,LDAPsearch必须返回一个值 ,否则您将无法确定将使用多个条目中的哪一个来检查密码。 为了达到这个目的,你可以使用范围( one
而不是sub
)或一个searchfilter来限制返回的条目数量。
附加文件必须添加到您的<Location>
或任何<VirtualHost>
指令之外的apacheconfiguration。 它必须包含在你的apacheconfiguration的根目录下。 当然, authn_alias
模块需要被激活。