公司之前用的都是由我部署的 LDAP , 前些日子升级了成 Windows 的域控,类似 Jenkins, Harbor 和 Gitlab 这些已接入账号管理的都要重新配置,这里记录下 Gitlab 的修改记录.
Gitlab 使用的是官方的 Docker 容器,将容器内的/etc/gitlab
挂载出来,编辑其中的gitlab.rb
文件.
找到gitlab_rails['ldap_enabled'] = true
,去掉前面的注释,编辑下方的 YAML.load:
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'ad.example.com'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
# 绑定的管理员账号应该使用特定的群组权限的账号
bind_dn: 'cn=Administrator,cn=Users,dc=ad,dc=example,dc=com'
password: 'password'
timeout: 10
active_directory: true
allow_username_or_email_login: true
block_auto_created_users: false
base: 'dc=ad,dc=example,dc=com'
# 过滤规则根据公司详细情况而定
#user_filter: '(&(objectClass=person)(memberOf=cn=xxx,cn=groups,dc=xxx,dc=xxx))'
attributes:
username: ['sAMAccountName']
email: ['mail']
name: 'displayName'
first_name: 'givenName'
last_name: 'sn'