Gitlab加入LDAP认证 (windows AD)<03>

环境信息:

主机名称 IP 角色
AD-Server 192.168.61.237 AD服务器
gitlab 192.168.61.112 AD服务器

[root@gitlab ~]# curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@gitlab ~]# yum -y install gitlab-ce


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: 'AD认证'
     host: '192.168.61.237'
     port: 389
     uid: 'SamaccountName'
     method: 'plain' # "tls" or "ssl" or "plain"
     bind_dn: 'cn=administrator,cn=Users,dc=iyou,dc=com'
     password: 'Lahmy1c!'
     active_directory: true
     allow_username_or_email_login: true
     block_auto_created_users: false
     base: 'dc=iyou,dc=com'
     user_filter: ''
EOS

重新加载配置

[root@gitlab ~]# gitlab-ctl reconfigure

查看是否能正常获取用户列表

gitlab-rake gitlab:ldap:check

参数说明:

  • host 、port :是 LDAP 服务的主机IP和端口。
  • bind_dn :管理 LDAP 的 dn。指定ldap服务器的管理员信息,即cn=账户,cn=组织单位。
  • base:表 LDAP 将以该 dn 为 节点,向下查找用户。ldap服务器的base域。
  • user_filter:表以某种过滤条件筛选用户。为空表示不过滤。

确认该用户不处于特殊状态
1.不处于“禁用账户”的状态;

2.不处于“需要首次登录修改密码”的状态;

(处于上面任意一种状态的账户在登录gitlab时都会报“Cloud not authenticate you from Ldapmain because "Invalid creadentials".”)

posted @ 2023-11-04 21:49  一毛丶丶  阅读(237)  评论(0编辑  收藏  举报