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 用户状态的请求:
判断用户状态码: