Apache LDAP認証に時間がかかりすぎる

Apache LDAP認証に時間がかかりすぎる

Active DirectoryにLDAP認証を提供するようにapache2.2(CentOS 5.6)を設定しました。

<Directory "/var/www/html">

        AuthType Basic
        AuthName "Authenticate with domain account."
        AuthBasicProvider ldap
        AuthzLDAPAuthoritative on
        AuthLDAPBindDN cn=Administrator,cn=users,dc=example,dc=com
        AuthLDAPBindPassword secret
        AuthLDAPURL ldap://192.168.56.110:389/dc=example,dc=com?sAMAccountName?sub?(objectClass=*)
        Require valid-user
        ...
</Directory>

動作しますが、時間が長すぎます。 tcpdump を使用してトラフィックを分析しました。タイムスタンプは、searchResEntry(Active DirectoryがログインしようとしているユーザーアカウントのDNで応答するとき)とbindRequest(Apacheが要求されたユーザーにバインドしようとしたとき)の間に正確に4分を表示します。

これはerror_log出力です:

[Sat Dec 10 07:06:37 2011] [debug] mod_authnz_ldap.c(390): [client 192.168.56.1] [2488] auth_ldap authenticate: using URL ldap://192.168.56.110:389/dc=example,dc=com?sAMAccountName?sub?(objectClass=*)

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(489): [client 192.168.56.1] [2488] auth_ldap authenticate: accepting peter

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(971): [client 192.168.56.1] [2488] auth_ldap authorise: declining to authorise

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(390): [client 192.168.56.1] [2475] auth_ldap authenticate: using URL ldap://192.168.56.110:389 dc=example,dc=com?sAMAccountName?sub?(objectClass=*), referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(489): [client 192.168.56.1] [2475] auth_ldap authenticate: accepting peter, referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(971): [client 192.168.56.1] [2475] auth_ldap authorise: declining to authorise, referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [error] [client 192.168.56.1] File does not exist: /var/www/html/projeto/style.css, referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(390): [client 192.168.56.1] [2475] auth_ldap authenticate: using URL ldap://192.168.56.110:389/dc=example,dc=com?sAMAccountName?sub?(objectClass=*), referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(489): [client 192.168.56.1] [2475] auth_ldap authenticate: accepting peter, referer: http://192.168.56.200/projeto/

[Sat Dec 10 07:10:37 2011] [debug] mod_authnz_ldap.c(971): [client 192.168.56.1] [2475] auth_ldap authorise: declining to authorise, referer: http://192.168.56.200/projeto/

ご覧のとおり、最初の行と2番目の行の間に4分かかります。

どんな手がかりがありますか?

市。ここに一つあります。協会Wiresharkを使用して表示されるtcpdumpキャプチャに。ご覧のとおり、Active Directoryはすぐに応答します。あまりにも時間がかかるのはApacheのバインディング要求です(画像で強調表示されています)。

ベストアンサー1

あなたのLDAPクエリがあまりにも「一般的」です。あまりにも多くの情報を取得しないようにクエリを実行する前にオブジェクトクラスを制限した場合はどうなりますか?

ldap://192.168.56.110:389/dc=example,dc=com?sAMAccountName?sub?(objectClass=user)

ldapsearchを使用して「手動で」クエリを行う場合、同じパフォーマンスの問題はありますか?前任者:

ldapsearch -x -W -D "cn=Administrator,dc=example,dc=com" -h 192.168.56.110 -b "dc=example,dc=com" -LLL "(SAMAccountName=peter)" 
Enter LDAP Password: 

おすすめ記事