在AuthLDAPURL中有更多Searchfilters

在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!

我想你的意思是寻找属性uidmail (而不是过滤)。 虽然RFC 2255允许在LDAP URL中使用两个不同的属性,但这是不可能的。

单独mod_authnz_ldap:不可能

Apache mod_authnz_ldap文档声明URL必须如下所示: ldap://host:port/basedn?attribute?scope?filter with

  • 属性 :要search的属性。 尽pipeRFC 2255允许使用逗号分隔的属性列表,但只有第一个属性会被使用,无论提供了多less个属性 。 如果没有提供任何属性,默认是使用uid。 select一个将在您将使用的子树中的所有条目中唯一的属性是个不错的主意。
  • filter :有效的LDAPsearchfilter。 如果未提供,则默认为(objectClass = *),它将search树中的所有对象。 filter被限制为大约8000个字符(Apache源代码中的MAX_STRING_LEN的定义)。 对于任何应用来说,这应该足够了。

使用2个提供者和mod_authn_alias

但是,添加另一个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模块需要被激活。