2

我正在尝试为我们的 GitLab 添加 LDAP 功能。我们有一个运行在 Windows 上的 ActiveDirectoy 服务器。Gitlab 本身托管在 ubuntu 服务器机器上。对于身份验证,我们在广告服务器上创建了一个 serverice-user。这是我的gitlab.rb文件(仅显示 ldap 配置。)

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main:
     label: 'LDAP'
     host: '1.2.3.4'
     port: 389
     uid: 'serviceAcc'
     bind_dn: 'CN=serviceACC,OU=Org 1,DC=organisation,DC=com'
     password: 'supersecurePass'
     encryption: 'plain'
     active_directory: true
EOS

未列出的选项被注释掉(因此将使用默认值)。接下来我执行这两个命令:

sudo gitlab-ctl reconfigure
sudo gitlab-rake gitlab:ldap:check

这是最后一条命令的结果:

Checking LDAP ...

LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)

Checking LDAP ... Finished

为什么我的列表是空的?不应该列出广告的所有用户吗?我还尝试应用存储用户的 base_dn 选项。

如果我做一个lsdapsearch我得到结果:

ldapsearch -H ldap://1.2.3.4 -x -W -D "serviceAcc@organisation.com" -b "dc=organisation,dc=com" "(objectClass=user)" mail

.
.
.
# serviceACC, Org 1, organisation.com
dn: CN=serviceACC,OU=Org 1,DC=organisation,DC=com
.
.
.

所以 AD 服务器可以访问并响应我的 ldapsearch 查询。我在 gitlab.rb 配置中遗漏了什么吗?

我正在使用版本 12.5.3 的 gitlab EE

更新 以下是@EricLavault 要求的详细信息:

  1. 用户名:user.1 ; dn:CN=用户 1,OU=公司员工,DC=公司,DC=com
  2. 用户提交其 AD 凭据:用户名:user.1 PW:#his AD-PW#
  3. 对于错误日志,我可以为您提供 production.log。如果您需要更多日志,请告诉我:
Started POST "/users/auth/ldapmain/callback" for 1.2.3.8 at 2019-12-11-07:48:59 +0000
Processing by OmniauthCallbacksController#failure as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "username"=>"user.1", "password"=>"[FILTERED]"}
Redirected to https://git.company.com/users/sign_in

出于安全原因,我必须用虚拟值更改实际值。但请相信我,提供的用户详细信息与实际值相似。(带有“.”的用户名,服务用户在另一个OU中,而不是将登录到gitlab的用户)

将向用户显示以下错误消息:

无法从 Ldapmain 对您进行身份验证,因为“user.1 的凭据无效”。

凭据是正确的。

4

1 回答 1

1

首先,您需要修复uid设置。它应该包含用户名属性,而不是映射到用户名的值。由于您的目标是广告,因此这应该是 sAMAccountNameuserPrincipalName(例如,分别匹配usernameusername@domain.com)。

如果使用sAMAccountNameas uid并且万一用户username@domain.com在登录时提交格式(而不仅仅是username),您需要设置allow_username_or_email_login: true(默认为 false)。

否则,如果userPrincipalName用作 uid,则必须将其设置为false.

然后,您可以设置将base搜索范围缩小到仅用户,如果您不确定用户在目录中的位置,只需像使用 ldapsearch: 一样设置域组件base: 'dc=organisation,dc=com'

您还可以像使用 ldapsearch 一样设置过滤器:user_filter: '(objectClass=user)'

回顾:

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main:
     label: 'LDAP'
     host: '1.2.3.4'
     port: 389
     uid: 'sAMAccountName'
     bind_dn: 'CN=serviceACC,OU=Org 1,DC=organisation,DC=com'
     password: 'supersecurePass'
     encryption: 'plain'
     active_directory: true
     allow_username_or_email_login: true
     base: 'dc=organisation,dc=com'
     user_filter: '(objectClass=user)'
EOS
于 2019-12-09T13:16:36.147 回答