gitlab配置LDAP
一、接入openldap
1.1 修改配置文件gitlab.rb
在gitlab.rb文件中添加下面配置,其中:
1.host,是搭建的openldap的ip,根据实际情况修改;
2.uid,可以配置cn,也可以配置uid,都能识别(具体为什么没深入研究);
3.bind_dn,openldap的管理员账号,根据实际情况修改;
4.password,openldap的管理员,根据实际情况修改;
5.active_directory,似乎是针对连接是否是ad域控的标示,因为这部分是openldap的配置,故为false;
6.allow_username_or_email_login,用户登录是否用户名和邮箱都可以,方便用户故配置true;
7.base,用户列表所在的目录,因为新增的用户都在openldap的People下,故这么配置,根据实际情况修改;
# 指明服务的地址
external_url = 'http://localhost'
# 开启ldap
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' ###! **remember to close this block with 'EOS' below**
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '192.168.6.4'
port: 389
uid: 'uid'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'cn=Manager,dc=abc,dc=cn'
password: '123456'
active_directory: false
allow_username_or_email_login: true
block_auto_created_users: false
base: 'ou=People,dc=abc,dc=cn'
user_filter: ''
EOS
1.2 重新加载新配置
# gitlab-ctl reconfigure
运行后最后一行为“gitlab Reconfigured!”才说明是加载新配置成功,否则就是根据报错信息找错误。
1.3 查看是否能正常获取用户列表
# gitlab-rake gitlab:ldap:check
正常连接的情况下执行之后能看到用户的列表
1.4 重启gitlab
# gitlab-ctl restart
二、接入AD
2.1 修改配置文件gitlab.rb
在gitlab.rb文件中添加下面配置,其中:
1.host,是搭建的微软域服务器的ip,根据实际情况修改;
2.uid,必须配sAMAccountName才能识别;
3.bind_dn,域服务器的管理员账号,根据实际情况修改;
4.password,域服务器的管理员,根据实际情况修改;
5.active_directory,似乎是针对连接是否是ad域控的标示,因为这部分是域服务器的配置,故为true;
6.allow_username_or_email_login,用户登录是否用户名和邮箱都可以,方便用户故配置true;
7.base,用户列表所在的目录,因为新增的用户都在People下(试验了用户放在User时gitlab检测不到用户,故新建了一个目录People,并将新建的用户移入了该目录下),故这么配置,根据实际情况修改;
external_url = 'http://localhost'
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' ###! **remember to close this block with 'EOS' below**
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '192.168.6.1'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'cn=Administrator,cn=users,dc=myad,dc=cn'
password: '123456'
active_directory: true
allow_username_or_email_login: true
block_auto_created_users: false
base: 'ou=People,dc=myad,dc=cn'
user_filter: ''
EOS
2.2 重新加载新配置
# gitlab-ctl reconfigure
运行后最后一行为“gitlab Reconfigured!”才说明是加载新配置成功,否则就是根据报错信息找错误。
2.3 查看是否能正常获取用户列表
# gitlab-rake gitlab:ldap:check
正常连接的情况下执行之后能看到用户的列表
2.4 重启gitlab
# gitlab-ctl restart