Gitlab 11.0.3漢化完成後,須要集成域控,現將域控的配置過程描述以下:html
gitlab目錄:/etc/gitlabnginx
gitlab配置文件:/etc/gitlab/gitlab.rbgit
編輯gitlab.rb文件:docker
在gitlab.rb文件中修改下面配置,其中:shell
1.host,是搭建的ldap的ip,根據實際狀況修改;windows
2.uid,能夠配置cn,也能夠配置uid,都能識別(具體爲何沒深刻研究);bash
3.bind_dn,ldap的管理員帳號,根據實際狀況修改;服務器
4.password,ldap的管理員,根據實際狀況修改;dom
5.active_directory,彷佛是針對鏈接是不是ad域控的標示,由於這部分是ldap的配置,故爲false;ssh
6.allow_username_or_email_login,用戶登陸是否用戶名和郵箱均可以,方便用戶故配置true;
7.base,用戶列表所在的目錄,由於新增的用戶都在ldap的People下,故這麼配置,根據實際狀況修改;
個人配置以下:
gitlab_rails['ldap_enabled'] = true
###! **remember to close this block with 'EOS' below**
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '**.**.**.**'
port: 389
uid: 'sAMAccountName'
bind_dn: 'cn=***,cn=Users,dc=***,dc=****,dc=COM'
password: '*****'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: true
active_directory: true
allow_username_or_email_login: true
lowercase_usernames: false
block_auto_created_users: false
base: 'OU=Users,OU=*****,DC=***,DC=*****,DC=COM'
user_filter: ''
## EE only
# group_base: ''
# admin_group: ''
# sync_ssh_keys: false
#
# secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
# label: 'LDAP'
# host: '_your_ldap_server'
# port: 389
# uid: 'sAMAccountName'
# bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
# password: '_the_password_of_the_bind_user'
# encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
# verify_certificates: true
# active_directory: true
# allow_username_or_email_login: false
# lowercase_usernames: false
# block_auto_created_users: false
# base: ''
# user_filter: ''
# ## EE only
# group_base: ''
# admin_group: ''
# sync_ssh_keys: false
EOS
重要配置參數解釋(仔細閱讀上一篇svn集成LDAP認證的文章這些參數會更好理解):
- host:LDAP服務器地址
- port:LDAP服務端口
- uid:以哪一個屬性做爲驗證屬性,能夠爲uid、cn等,咱們使用uid
- method:若是開啓了tls或ssl則填寫對應的tls或ssl,都沒有就填寫plain
- bind_dn:search搜索帳號信息的用戶完整bind(須要一個有read權限的帳號驗證經過後搜索用戶輸入的用戶名是否存在)
- password:bind_dn用戶的密碼,bind_dn和password兩個參數登陸LDAP服務器搜索用戶
- active_directory:LDAP服務是不是windows的AD,咱們是用的OpenLDAP,這裏寫false
- allow_username_or_email_login:是否容許用戶名或者郵箱認證,若是是則用戶輸入用戶名或郵箱均可
- base:從哪一個位置搜索用戶,例如容許登陸GitLab的用戶都在ou gitlab裏,name這裏能夠寫ou=gitlab,dc=domain,dc=com
- filter:添加過濾屬性,例如只過濾employeeType爲developer的用戶進行認證(employeeType=developer)
配置完成後進行配置更新:
gitlab-ctl reconfigure
檢查是否配置成功:
gitlab-rake gitlab:ldap:check(列出前100個用戶)
重啓gitlab服務:
gitlab-ctl restart
注意: 確認該用戶不處於特殊狀態
1.不處於「禁用帳戶」的狀態;
2.不處於「須要首次登陸修改密碼」的狀態;
(處於上面任意一種狀態的帳戶在登陸gitlab時都會報「Cloud not authenticate you from Ldapmain because "Invalid creadentials".」)
下圖是發出的search 用戶狀態的請求:
判斷用戶狀態碼: