sir*_*ide 8 ubuntu active-directory ldap gitlab ubuntu-14.04
我正在尝试使用 GitLab 设置 LDAP 身份验证(在 VM 上的 Ubuntu 14.04 amd64 上安装了 7.12.2 版,Omnibus 设置)。我已将 gitlab.rb 文件编辑为如下所示:
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: '********'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'CN=********,OU=********,OU=********,DC=********,DC=***'
password: '********'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'DC=********,DC=***'
user_filter: ''
EOS
Run Code Online (Sandbox Code Playgroud)
这会导致可怕的“无法从 Ldapmain 授权您,因为“凭据无效”。错误。我试过,用户名(在 bind_dn 变量中):“johnsmith@example.com”(基于用户名的电子邮件)、“John Smith”(全名)和“johnsmith”(用户名)。结果总是一样的。我的密码中确实有一个@-sign。我不确定我是否需要逃避它,或者如何逃避。
日志显示:
Started POST "/users/auth/ldapmain/callback" for 127.0.0.1 at 2015-07-22 17:15:01 -0400
Processing by OmniauthCallbacksController#failure as HTML
Parameters: {"utf8"=>"?", "authenticity_token"=>"[FILTERED]", "username"=>"********", "password"=>"[FILTERED]"}
Redirected to http://192.168.56.102/users/sign_in
Completed 302 Found in 14ms (ActiveRecord: 3.6ms)
Started GET "/users/sign_in" for 127.0.0.1 at 2015-07-22 17:15:01 -0400
Processing by SessionsController#new as HTML
Completed 200 OK in 20ms (Views: 8.3ms | ActiveRecord: 2.9ms)
Run Code Online (Sandbox Code Playgroud)
并gitlab-rake gitlab:ldap:check显示:
Checking LDAP ...
LDAP users with access to your GitLab server (only showing the first 100 results)
Server: ldapmain
Checking LDAP ... Finished
Run Code Online (Sandbox Code Playgroud)
但是,当我从 Ubuntu VM(相同的环境)使用 ldapsearch 时,我确实得到了一堆结果:
ldapsearch -x -h ******** -D "********@********.***" -W -b "OU=********,OU=********,DC=********,DC=***" -s sub "(cn=*)" cn mail sn dn
Run Code Online (Sandbox Code Playgroud)
奇怪的是,结果中的 DN 如下所示:
dn: CN=John Smith,OU=********,OU=********,OU=********,DC=********,DC=***
Run Code Online (Sandbox Code Playgroud)
也就是说,那里有一个额外的 OU。我还看到 ldapsearch 命令有-s sub,我相信这意味着搜索子组。我对 LDAP 或 Active Directory 的来龙去脉并不十分熟悉。
所以我相信我在我的基地中遗漏了一些东西,但我不确定是什么。也可能是用户过滤器的问题。我已经完成了必要的谷歌搜索,这让我走到了这一步,但现在我没有想法和解决方案。
sir*_*ide 11
经过多次不同的尝试,我能够解决这个问题。一些注意事项:
这是最终的 YAML:
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'Active Directory'
host: 'ad-server.example.com'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'user@example.com'
password: 'password'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'OU=ABC,OU=XYZ,DC=example,DC=com'
user_filter: ''
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6616 次 |
| 最近记录: |