Apache-2.2

LDAP 身份驗證失敗,返回 500 或 401,具體取決於 Apache2 的綁定

  • November 16, 2012

我正在為通過 Apache 在 RHEL 5 系統上託管的 Subversion 儲存庫設置 LDAP 身份驗證。當我嘗試針對 Active Directory 進行身份驗證時,我遇到了兩個不同的問題。

<Location /svn/>
Dav svn
SvnParentPath /srv/subversion
SVNListParentPath On
AuthType Basic
AuthName "Subversion Repository"

AuthBasicProvider ldap

AuthLDAPBindDN "cn=userfoo,ou=Service Accounts,ou=User Accounts,dc=my,dc=example,dc=com"
AuthLDAPBindPassword "mypass"

AuthLDAPUrl "ldap://my.example.com:389/ou=User Accounts,dc=my,dc=example,dc=com?sAMAccountName?sub?(objectClass=user)" NONE

Require valid-user
</Location>

如果我使用上述配置,它會不斷提示我基本提示,我最終必須選擇取消,這將返回 401(需要授權)。如果我註釋掉綁定部分,它會返回 500(內部伺服器錯誤),說明身份驗證失敗:

[Mon Nov 02 12:00:00 2009] [warn] [client x.x.x.x] [10744] auth_ldap authenticate: user myuser authentication failed; URI /svn [ldap_search_ext_s() for user failed][Operations error]

當我使用 ldapsearch 執行綁定並過濾一個簡單屬性時,它會正確返回:

ldapsearch -h my.example.com -p 389 -D "cn=userfoo,ou=Service Accounts,ou=User Accounts,dc=my,dc=example,dc=com" -b "ou=User Accounts,dc=my,dc=example,dc=com" -w - "&(objectClass=user)(cn=myuser)" sAMAccountName

不幸的是,我無法控製或了解系統的 AD 部分,只有 RHEL 伺服器。有誰知道這裡的掛斷是什麼?

我有同樣的問題。我在 Ubuntu 上測試的相同配置在 RHEL5 上不起作用。在閱讀完這篇文章後,我最終從埠 389 更改為 3268 ,這解決了我的問題。

將您的配置與 Apache 2.2.3 上的 Active Directory 的工作配置進行比較,我看到的唯一區別是:

  • 我正在使用“DOMAIN\sAMAccountName”樣式的使用者名AuthLDAPBindDN
  • 我沒有NONE後我AuthLDAPURL

除了這些建議之外,我還建議執行tcpdumpApache 和 Active Directory 之間的對話,看看那裡也可能發生什麼。

引用自:https://serverfault.com/questions/80762