我正在尝试使用GitLab(安装在Ubuntu 14.04 amd64上的VM,Omnibus安装版本7.12.2)来设置LDAP身份validation。 我已经编辑了我的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
这会导致可怕的“无法授权您从Ldapmain,因为”无效的凭据“。 错误。 我已经尝试了用户名(在bind_dnvariables中):“[email protected]”(基于用户名的电子邮件),“John Smith”(全名)和“johnsmith”(用户名)。 结果总是一样的。 我的密码里有一个@符号。 我不确定是否需要逃避它,或者如何。
日志显示:
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)
和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
但是,当我从Ubuntu VM使用ldapsearch(如此相同的环境),我得到了一堆结果:
ldapsearch -x -h ******** -D "********@********.***" -W -b "OU=********,OU=********,DC=********,DC=***" -s sub "(cn=*)" cn mail sn dn
奇怪的是,DN中的结果如下所示:
dn: CN=John Smith,OU=********,OU=********,OU=********,DC=********,DC=***
也就是说,那里有一个额外的OU。 我也看到,ldapsearch命令有-s sub ,我相信这意味着search子组。 我对LDAP或Active Directory的来龙去脉并不是十分熟悉的。
所以我相信我错过了我的基地,但我不知道是什么。 用户filter也可能是一个问题。 我做了必要的谷歌search,这让我走了这么远,但现在我没有想法和解决scheme。
经过许多不同的尝试,我能够解决这个问题。 一些注意事项:
这是最后的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: '[email protected]' 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: ''