mod_authz_ldap子树查询配置失败,而是搜索LDAP树的根

时间:2012-09-04 08:53:37

标签: authentication configuration ldap apache

我正在尝试查询一个奇怪的LDAP结构,我需要对其进行身份验证。我们的应用程序使用REMOTE_USER变量来确定用户。我无法访问LDAP目录,因此无法查看它的日志。

结构需要我查询树的子部分,这个Perl脚本用来测试LDAP查询(它按预期工作并返回用户列表)来演示。

use Net::LDAP;
use Net::LDAP::Entry;

$ldap = Net::LDAP->new( 'ldapdevel.my.edu.au' ) or die "$@";
$mesg = $ldap->bind( 'uid=binduser,o=my.edu.au', password => 'bindpass' );


if( $mesg->code ) {
               die $mesg->error;
 }

$mesg = $ldap->search( # perform a search
        base   => "o=my.edu.au",
        filter => "cn=devraj"
      );


$mesg->code && die $mesg->error;

foreach $entry ($mesg->entries) { 
             $entry->dump;
}

我的Apache配置在VirtualHost条目中有以下内容,其目的是模仿Perl脚本中描述的相同查询。

<Location />

    AuthType Basic
    AuthName "My Application"

    AuthBasicProvider ldap
    AuthzLDAPAuthoritative off
    AuthLDAPBindPassword bindpass

    AuthLDAPBindDN "uid=binduser,o=my.edu.au"
    AuthLDAPUrl "ldap://ldapdevel.my.edu.au/o=my.edu.au?cn?one"

    Require valid-user

</Location>

我还可以确认Apache是​​否成功绑定到LDAP目录。

Apache错误日志,用于LDAP身份验证的消息,表示URI是/因此Apache正在搜索目录的顶部而不是o = my.edu.au

的子树
[Tue Sep 04 16:22:01 2012] [notice] Apache/2.2.15 (Unix) DAV/2 mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations
[Tue Sep 04 16:22:20 2012] [info] [client xxx.xxx.xxx.xxx] [26064] auth_ldap authenticate: user devraj authentication failed; URI / [User not found][No such object]
[Tue Sep 04 16:22:20 2012] [error] [client xxx.xxx.xxx.xxx] user devraj not found: 

我意识到问题是AuthLDAPUrl,我的问题是我在AuthLDAPUrl中做错了什么,或者我应该使用另一个指令?

我还尝试将每个参数单独配置为mod_authz_ldap,如下所示:

<Location />

    AuthType Basic
    AuthName "My LDAP authenticated app"

    AuthzLDAPLogLevel debug

    AuthBasicProvider ldap
    AuthBasicAuthoritative off
    AuthzLDAPAuthoritative off

    AuthzLDAPBindPassword bindpass
    AuthzLDAPBindDN "uid=binduser,o=my.edu.au"

    AuthzLDAPMethod ldap
    AuthzLDAPServer ldapdevel.my.edu.au
    AuthzLDAPUserBase o=my.edu.au
    AuthzLDAPUserKey cn
    AuthzLDAPUserScope base
    AuthLDAPRemoteUserAttribute cn

    Require valid-user

</Location>

这实际上有效!但是...... Apache试图以尝试登录的用户绑定,这显然会失败。如果我使用绑定用户凭据登录,则会通过身份验证,错误日志提取:

[Fri Sep 07 14:14:27 2012] [error] [client xxx.xxx.xxx.xxx] [15628] bind as cn=devraj,l=X,ou=Students,o=my.edu.au failed: 49
[Fri Sep 07 14:14:27 2012] [error] [client xxx.xxx.xxx.xxx] [15628] basic LDAP authentication of user 'devraj' failed
[Fri Sep 07 14:14:27 2012] [error] [client xxx.xxx.xxx.xxx] access to / failed, reason: verification of user id 'devraj' not configured

感谢您的时间。

0 个答案:

没有答案