作者 主題: Git 如何與AD整合?  (閱讀 23082 次)

0 會員 與 1 訪客 正在閱讀本文。

b7307024

  • 懷疑的國中生
  • **
  • 文章數: 43
    • 檢視個人資料
Git 如何與AD整合?
« 於: 2018-01-22 17:51 »
我參考這篇文章,初步將Git Server架設起來
http://wernbin.pixnet.net/blog/post/45716002-windows%E6%9E%B6git-server%E7%9A%84%E5%AE%89%E8%A3%9D%E6%B5%81%E7%A8%8B%E7%B4%80%E9%8C%84

其中 "為目錄http://ip_addr/git增加權限"
htpasswd -cmb /C/Kelvin/GitRepos/htpasswd root calvin
不管怎麼試,就是會跳出 htpasswd: command not found
最後用命令提示字元,再次嘗試才產生出htpasswd檔案,
測試可以正常Clone、Sync及Commit,所以算是成功架設完成。

現在要嘗試將認證整合AD,參考了這篇
https://beginor.github.io/2013/03/01/config-apache-git-server-on-windows.html
但不管怎麼試都不能成功認證,上網找apache ldap設定也搞不出來,我的設定內容如下:
代碼: [選擇]
<Location /git/>
AuthType Basic
AuthName "Git Repository"
AuthBasicProvider ldap
AuthLDAPURL "ldap://xxx.com:389/OU=yahoo,DC=yahoo,DC=com?cn?sub?(objectClass=*)" 
AuthzLDAPAuthoritative on
AuthLDAPBindDN "xxx@yahoo.com"
AuthLDAPBindPassword 123456
AuthLDAPGroupAttributeIsDN on
AuthLDAPGroupAttribute member
Require valid-user
</Location>

請問是哪裡有錯誤嗎?感激不盡。
« 上次編輯: 2018-01-23 15:18 由 b7307024 »

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5416
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
Re: Git 如何與AD整合?
« 回覆 #1 於: 2018-01-23 13:01 »
你確定你的 DN 是對的? 正常來說 DN 不會是 email 那個格式.
我們用的是類似這樣的設定.
代碼: [選擇]
        <Location />
                AuthName "GIT: Enter AD Username/Password"
                AuthType Basic
                AuthBasicProvider ldap
                AuthLDAPBindDN "CN=git,CN=Users,DC=domain,DC=xxx,DC=org,DC=tw"
                AuthLDAPBindPassword "password"
                AuthLDAPURL "ldap://ad.domain.xxx.org.tw:3268/DC=domain,DC=xxx,DC=org,DC=tw?sAMAccountName?sub?(objectClass=*)"
                #AuthLDAPMaxSubGroupDepth 10
                #AuthLDAPSubgroupAttribute member
                AuthLDAPSubGroupClass group
                #AuthLDAPGroupAttribute member
                AuthLDAPGroupAttributeIsDN on
                require ldap-group CN=DEPT_xxx,DC=domain,DC=xxx,DC=org,DC=tw
                ErrorDocument 401 "Please use AD username and password to login GIT."
        </Location>

b7307024

  • 懷疑的國中生
  • **
  • 文章數: 43
    • 檢視個人資料
Re: Git 如何與AD整合?
« 回覆 #2 於: 2018-01-23 15:51 »
回報twu2大,我參考了你的代碼後修改我的代碼,測試還是不能正常啟動apache.
代碼: [選擇]
<Location /git/>
AuthName "Git Repository"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPBindDN "CN=Administrator,DC=xxxxxx,DC=com"
    AuthLDAPBindPassword "123456"
AuthLDAPURL "ldap://xxxx.xxxxx.com:389/DC=xxxxx,DC=com?sAMAccountName?sub?(objectClass=*)"
AuthzLDAPAuthoritative on
AuthLDAPSubGroupClass group
AuthLDAPGroupAttributeIsDN on
Require valid-group CN=mis_group,DC=xxxxxx,DC=com
ErrorDocument 401 "Please use AD username and password to login GIT."
</Location>

DC=xxxxxx是打網域名稱,如:yahoo

AuthLDAPBindDN "CN=Administrator,DC=xxxxxx,DC=com"  此處CN我是使用網域管理帳號Administrator

AuthLDAPURL "ldap://xxxx.xxxxx.com:389/DC=xxxxx,DC=com?sAMAccountName?sub?(objectClass=*)" xxxx.xxxxx.com:389  是主機名稱.網域名稱,如:test.yahoo.com

啟動apache的錯誤訊息如下:

twu2

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 5416
  • 性別: 男
    • 檢視個人資料
    • http://blog.teatime.com.tw/1
Re: Git 如何與AD整合?
« 回覆 #3 於: 2018-01-23 17:09 »
那個 port 3268 不是隨便一個 port... 改成 ldap 的標準 port 389 是不能用在 Windows AD 上頭的.

https://httpd.apache.org/docs/trunk/mod/mod_authnz_ldap.html#activedirectory
« 上次編輯: 2018-01-23 17:10 由 twu2 »

netman

  • 管理員
  • 俺是博士!
  • *****
  • 文章數: 17484
    • 檢視個人資料
    • http://www.study-area.org
« 上次編輯: 2018-01-25 15:05 由 netman »