Apache-2.2

使用 mod_authn_alias 從 AD 中的多個域進行 Apache 身份驗證

  • June 27, 2012

我正在執行 Apache 2,我需要對來自多個 AD 域的使用者進行身份驗證<Location/>。我嘗試使用mod_authn_alias

ОС: Debian GNU/Linux Squueze 最新更新

Apache/2.2.16

模組

/etc/apache2/apache.conf:

<AuthnProviderAlias ldap first-ldap>
   AuthLDAPURL "ldap://win2003server:389/DC=first,DC=domain?sAMAccountName?sub?(objectClass=*)" NONE
   AuthLDAPBindDN "cn=user1,cn=Users,dc=first,dc=domain"
   AuthLDAPBindPassword "user1"
</AuthnProviderAlias>

<AuthnProviderAlias ldap second-ldap>
   AuthLDAPURL "ldap://win2008server:3268/DC=second,DC=domain?sAMAccountName?sub?(objectClass=*)" NONE
   AuthLDAPBindDN "cn=user2,cn=Users,dc=second,dc=domain"
   AuthLDAPBindPassword "user2"
</AuthnProviderAlias>

/etc/apache2/sites-enabled/000default:

<Location /test>

   Order allow,deny
   Allow from all

   Authtype Basic
   AuthBasicProvider first-ldap second-ldap
   AuthName "TEST"
   AuthzLDAPAuthoritative off
   require valid-user

</Location>

使用此配置,它會驗證來自第一個域的使用者,而對於來自第二個域的使用者,它會報錯:

[Fri Sep 16 20:54:39 2011] [info] [client 10.0.0.62] [25672] auth_ldap authenticate: user2 user2 authentication failed; URI /test/ [ldap_simple_bind_s() to check user2 credentials failed][Invalid credentials]

當我只留下AuthBasicProvider second-ldap第二個域的使用者可以成功驗證時,第二個域的 LDAP 就可以了。

有沒有人知道強制 mod_authn_alias 工作的解決方案?

我在這裡找到了解決方法:authenticating-apache-httpd-against-multiple-ldap-servers-with-expired-accounts

我用於測試來自第二個域的使用者帳戶,該帳戶在第一個域中具有同名禁用帳戶。刪除禁用的帳戶有幫助,但刪除 AD 域中的帳戶是不好的做法:您可以接收具有未知安全描述符的對象。我創建了 LDAP 過濾器來消除禁用使用者,現在一切正常:)

/etc/apache2/apache2.conf:

<AuthnProviderAlias ldap first-ldap>
   AuthLDAPURL "ldap://win2003server:389/DC=first,DC=domain?sAMAccountName?sub?(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" NONE
   AuthLDAPBindDN "cn=user1,cn=Users,dc=first,dc=domain"
   AuthLDAPBindPassword "user1"
</AuthnProviderAlias>

<AuthnProviderAlias ldap second-ldap>
   AuthLDAPURL "ldap://win2008server:3268/DC=second,DC=domain?sAMAccountName?sub?(&(objectCategory=person)(objectClass=user))" NONE
   AuthLDAPBindDN "cn=user2,cn=Users,dc=second,dc=domain"
   AuthLDAPBindPassword "user2"
</AuthnProviderAlias>

請注意,此過濾器適用於功能級別為“windows 2000 native”的 AD 域,不適用於功能級別為“windows server 2003”的 AD 域,我不知道為什麼。

我不知道如何讓 Apache 做你想做的事。ldap但是,您可以使用或後端將OpenLDAP 設置為多個 AD 實例前面的代理meta,這將使您有效地獲得相同的行為。您將 Apache 指向您的 OpenLDAP 代理,然後 OpenLDAP 與您的 AD 伺服器對話。

是我關於使用meta後端的文章。這更像是一個起點,而不是一個實際的解決方案。

我現在實際上使用 OpenLDAP 作為代理來針對三個單獨的目錄進行身份驗證——一個 AD 域、一個遠端 LDAP 伺服器和一個本地 LDAP 目錄。

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