部署说明
1 环境准备
搭建前提:已搭建gitlab-ce和内部AD域
IP地址 | 操作系统 | 软件版本 | AD域主机地址 |
---|---|---|---|
192.168.1.2 | Centos 7 | gitlab-ce-13.10.5 | 192.168.1.5 |
2 Gitlab配置LDAP
2.1 修改配置文件
gitlab中默认是关闭LDAP服务的,在默认配置文件/etc/gitlab/gitlab.rb中修改LDAP配置项,添加以下配置:
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'AD 认证'
host: '192.168.1.5'
port: 389
uid: 'sAMAccountName'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
bind_dn: 'CN=binduser,CN=Users,DC=example,DC=com'
password: '******'
verify_certificates: true
active_directory: true
allow_username_or_email_login: true
block_auto_created_users: false
base: 'ou=开发部,DC=example,DC=com'
user_filter: ''
EOS </pre>
相关参数说明:
label:登录页显示标签。
host 、port :是 LDAP 服务的主机IP和端口,默认为389。
bind_dn :管理 LDAP 的 dn(区分名)。指定ldap服务器的管理员信息,即cn=账户,cn=组织单位。(CN为对象,ou为组织单元,DC为域部分)
password:bind_dn的密码。
base:以该目录为 节点,向下查找用户。ldap服务器的base域。
user_filter:表以某种过滤条件筛选用户。
2.2 配置生效
[root@localhost ~]# gitlab-ctl reconfigure
[root@localhost ~]# gitlab-ctl restart