use*_*150 5 search filter mod-auth-ldap apache-2.2
在 AuthLDAPURL 中是否可以有多个搜索过滤器?
示例 uid 过滤器:
<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>
Run Code Online (Sandbox Code Playgroud)
我们需要搜索uid或mail。喜欢...
AuthLDAPURL ldap://example.test.com/o=test,c=com?uid|mail
Run Code Online (Sandbox Code Playgroud)
解决方案(它对我有用):
使用 Apache 2.4 测试 http://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>
Run Code Online (Sandbox Code Playgroud)
谢谢托宁!
我猜你的意思是寻找属性uid或mail(不过滤那些)。虽然RFC 2255允许,但不可能立即在 LDAP URL 中使用 2 个不同的属性。
阿帕奇mod_authnz_ldap模块文件规定的URL必须像:ldap://host:port/basedn?attribute?scope?filter用
但是,添加另一个 apache 模块,即mod_authn_alias,您可以使用 2 个不同的 LDAPURL 作为不同的身份验证提供程序。为此,您可以添加一个新文件(将包含在 apache 配置的根目录中),其中包含:
# 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>
Run Code Online (Sandbox Code Playgroud)
然后,在您的<Location>语句中,您使用以下配置:
<Location /test/>
AuthType Basic
AuthName "Test"
AuthBasicProvider ldap-uid ldap-mail
AuthUserFile /dev/null
require ldap-group cn=group01,o=test,c=com
</Location>
Run Code Online (Sandbox Code Playgroud)
这将首先尝试使用 进行身份验证uid,如果失败,请尝试使用该mail属性。使用这种类型的配置,您可以根据需要添加任意多个不同的 LDAPURL 提供程序。
但是,您必须注意一件事,LDAP 搜索必须返回单个值,否则您将无法确定将使用多个条目中的哪一个来检查密码。为此,您可以使用范围(one而不是sub)或搜索过滤器来限制返回的条目数。
附加文件必须添加到您的 apache 配置<Location>或任何<VirtualHost>指令之外。它必须包含在 apache 配置的根级别。和authn_alias模块的需求被激活,当然。
| 归档时间: |
|
| 查看次数: |
9280 次 |
| 最近记录: |