gitlab配置LDAP

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

257  gitlab_rails['ldap_enabled'] = true
258 
259 ###! **remember to close this block with 'EOS' below**
260  gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
261    main: # 'main' is the GitLab 'provider ID' of this LDAP server
262      label: 'LDAP' #
263      host: '192.168.13.189'
264      port: 389
265      uid: 'sAMAccountName'
266      method: 'plain'
267      bind_dn: 'cn=Administrator,cn=Users,dc=hongte,dc=info'
268      password: '!@1234qwe'
269 #     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
270 #     verify_certificates: true
271 #     smartcard_auth: false
272      active_directory: true
273      allow_username_or_email_login: false
274 #     lowercase_usernames: false
275      block_auto_created_users: false
276      base: 'ou=鸿特信息,dc=hongte,dc=info'
277      user_filter: ''
278 #     ## EE only
279 #     group_base: ''
280 #     admin_group: ''
281 #     sync_ssh_keys: false
282 #
283 #   secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
284 #     label: 'LDAP'
285 #     host: '_your_ldap_server'
286 #     port: 389
287 #     uid: 'sAMAccountName'
288 #     bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
291 #     verify_certificates: true
292 #     smartcard_auth: false
293 #     active_directory: true
294 #     allow_username_or_email_login: false
295 #     lowercase_usernames: false
296 #     block_auto_created_users: false
297 #     base: ''
298 #     user_filter: ''
299 #     ## EE only
300 #     group_base: ''
301 #     admin_group: ''
302 #     sync_ssh_keys: false
303  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


作者:Bin Xiao
来源:CSDN
原文:https://blog.csdn.net/xiaohuibin0541/article/details/83688307
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值