
這是我在這裡的第一篇文章,所以請善待我...
我們有 apache 來管理我們的 subversion 伺服器的存取。目前使用者只能使用其 sAMAccountName 登錄,但由於 userPrincipalName(電子郵件地址)逐漸成為大多數登入的主要 ID,我們希望支持這一點並保持對 sAMAccountName 的支持。
目前的方法如下所示,其缺點是必須在 svnaccessfile 中指定兩個使用者名稱 - sAMAccountName 和 userPrincipalName:
<AuthnProviderAlias ldap ldap-sAMAccountName>
AuthLDAPBindDN "CN=d-svn-ldap,OU=IT-050,OU=Service Accounts,OU=Accounts,OU=Domain Administration,DC=cds,DC=company"
AuthLDAPBindPassword ***
AuthLDAPUrl "ldap://server.company:3268/DC=cds,DC=company?sAMAccountName?sub?(objectclass=user)"
</AuthnProviderAlias>
<AuthnProviderAlias ldap ldap-userprincipalname>
AuthLDAPBindDN "CN=d-svn-ldap,OU=IT-050,OU=Service Accounts,OU=Accounts,OU=Domain Administration,DC=cds,DC=company"
AuthLDAPBindPassword ***
AuthLDAPUrl "ldap://server.company:3268/DC=cds,DC=company?userPrincipalName?sub?(objectclass=user)"
</AuthnProviderAlias>
<Location "/our_repo">
DAV svn
SVNPath /svn/repos/our_repo
SVNListParentPath on
AuthzSVNAccessFile /etc/apache2/conf-available/authz_repository_our_repo
Options Indexes Followsymlinks
AuthBasicProvider ldap-sAMAccountName ldap-userprincipalname
AuthType Basic
AuthName "LDAP authentication"
Require valid-user
# Note that Require ldap-* would not work here, since the
# AuthnProviderAlias does not provide the config to authorization providers
# that are implemented in the same module as the authentication provider.
</Location>
所以我正在尋找一種只能在 svnaccessfile 中指定 userPrincipalNames 的方法。我希望 AuthLDAPRemoteUserAttribute 可能會有所幫助,因此我添加
AuthLDAPRemoteUserAttribute userPrincipalName
到 ldap-sAMAccountName ,這導致 error.log 中出現此訊息:
auth_ldap 驗證:REMOTE_USER 將使用屬性「userPrincipalName」進行設置,但在使用者的 LDAP 查詢中未要求此屬性。 REMOTE_USER 將根據需要回退到使用者名稱或 DN。
這是正確的方法嗎?這可能嗎?
謝謝
弗洛
答案1
靈感來自https://svn.haxx.se/users/archive-2010-04/0011.shtml我們再次嘗試,找到如何查詢 ldap 的兩個欄位的解決方案:
<AuthnProviderAlias ldap ldap-sAMAccountName>
AuthLDAPBindDN "CN=d-svn-ldap,OU=IT-050,OU=Service Accounts,OU=Accounts,OU=Domain Administration,DC=cds,DC=company"
AuthLDAPBindPassword ***
AuthLDAPRemoteUserIsDN on
AuthLDAPUrl "ldap://server.company:3268/DC=cds,DC=company?sAMAccountName,userPrincipalName?sub?(objectclass=*)"
AuthLDAPRemoteUserAttribute userPrincipalName
</AuthnProviderAlias>
最後一行將 REMOTE_USER 轉換為 userPrincipalName 的內容。
由於我們公司的 userPrincipalName 包含帶有一些大寫字母的電子郵件地址,因此我們必須在 svnaccess 檔案中使用與電子郵件地址完全相同的大小寫。
為了只使用 userPrincipalName 而不是使用者輸入的內容 (REMOTE_USER),我們也必須為其他 AutnProviderAlias 指定 AuthLDAPRemoteUserAttribute:
<AuthnProviderAlias ldap ldap-userprincipalname>
AuthLDAPBindDN "CN=d-svn-ldap,OU=IT-050,OU=Service Accounts,OU=Accounts,OU=Domain Administration,DC=cds,DC=company"
AuthLDAPBindPassword ***
AuthLDAPUrl "ldap://server.company:3268/DC=cds,DC=company?userPrincipalName?sub?(objectclass=user)"
AuthLDAPRemoteUserAttribute userPrincipalName
</AuthnProviderAlias>
我們還必須更改提供者的順序:
AuthBasicProvider ldap-userprincipalname ldap-sAMAccountName
附註:error.log 僅顯示由於 ldap 結果而導致的拒絕,svnaccessfile 中缺少權限的情況不會顯示在那裡。因此,svn accessfile 中的變更無需重新啟動 apache 或刪除瀏覽器登入即可可見。