LDAP のデバッグ
注
これは omnibus インストールを前提としています。
ドキュメントの LDAP トラブルシューティングを参照してください - ドキュメントを表示
LDAP サーバーのテスト
ldapsearchをインストールします
# Ubuntu
apt-get install ldap-utils
# CentOS
yum install openldap-clients
- LDAP 設定を確認します
gitlab.rb の LDAP 設定に合わせて、以下の値を編集します。
LDAP 設定の例
# cat /etc/gitlab/gitlab.rb | grep -A 24 ldap_servers
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: '127.0.0.1'
port: 389
uid: 'uid'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'cn=admin,dc=ldap-testing,dc=mrchris,dc=me'
password: 'Password1'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'dc=ldap-testing,dc=mrchris,dc=me'
user_filter: ''
attributes:
username: ['uid', 'userid', 'sAMAccountName']
email: ['mail', 'email', 'userPrincipalName']
name: 'cn'
first_name: 'givenName'
last_name: 'sn'
group_base: 'ou=groups,dc=ldap-testing,dc=mrchris,dc=me'
admin_group: 'gitlab_admin'
EOS
LDAP search のスイッチ
-D = Bind DN
- GitLab 設定値:
bind_dn: 'cn=admin,dc=ldap-testing,dc=mrchris,dc=me'
- GitLab 設定値:
-b = Search base
- GitLab 設定値:
base: 'dc=ldap-testing,dc=mrchris,dc=me'
- GitLab 設定値:
-w = Password
- GitLab 設定値:
password: 'Password1'
- GitLab 設定値:
-w = Port & -h = Host
- GitLab 設定値:
port: 389 - GitLab 設定値:
host: 127.0.0.1
- GitLab 設定値:
-s = Search scope
- GitLab 設定値: なし
- デフォルトは sub
sub "(objectclass=*)を使うと “すべての” オブジェクトが返されます
baseDN のすべての LDAP オブジェクトを取得
ldapsearch -D "cn=admin,dc=ldap-testing,dc=mrchris,dc=me" \
-w Password -p 389 -h 127.0.0.1 \
-b "dc=ldap-testing,dc=mrchris,dc=me" -s sub "(objectclass=*)"
LDAP エラーメッセージ (production.log)
Could not find member DNs for LDAP group
Could not find member DNs for LDAP group #<Net::LDAP::Entry:0x00000007220388
これは通常、gitlab.rb の uid 設定値の問題を示しています。
ldapsearch を実行すると、LDAP のユーザー名にどの属性が使用されているかを確認できます。下記の場合、ユーザー名属性は uid です。設定で uid: 'uid' となっていることを確認してください。Microsoft Active Directory のデフォルトのユーザー名値は sAMAccountName です。
dn: cn=user test,ou=people,dc=ldap-testing,dc=mrchris,dc=me
sn: test
givenName: user
uid: test
cn: user test
Cannot find LDAP group with CN ‘GROUP_NAME’. Skipping
これは、admin_group 名が見つからなかったことを示します admin_group: 'gitlab_admin'。AD にグループが存在し、group_base の下にあることを確認してください。
LDAP search error: Invalid DN Syntax
これは、設定された DN のいずれかに構文エラーがあることを示します。次の値をチェックして、完全な DN であることを確認してください。
group_basebind_dnbase
LDAP のテスト - 8.10 以降に有効
Rails コンソールを起動します
gitlab-rails cロガーレベルを更新します
Rails.logger.level = 0グループ同期を実行します
LdapGroupSyncWorker.new.performユーザー同期を実行します
LdapSyncWorker.new.performすべてのコマンド:
gitlab-rails c Rails.logger.level = 0 LdapGroupSyncWorker.new.perform LdapSyncWorker.new.perform同期出力をコンソールで確認します
Exclusive lease の削除 - テスト用 (8.6 から 8.9 で有効)
これはテスト目的で LDAP の即座の同期を強制するために使用されます。
- 必要な LDAP 設定を編集します
vi /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/group_sync.rbを編集します- exclusive lease のセクションをコメントアウトします (リリースによって行が異なる場合があります) - コードを表示
- リコンフィグを実行します
sudo gitlab-ctl reconfigureこれは GitLab を再起動します - GitLab Rails コンソールを起動します
gitlab-rails console Gitlab::LDAP::GroupSync.executeを実行します- LDAP 同期が実行されます
- 完了したら
group_sync.rbファイルへの変更を元に戻します/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ldap/group_sync.rb
追加のテスト
Rails コンソールを起動します
sudo gitlab-rails console新しいアダプタインスタンスを作成します
adapter = ::Gitlab::Auth::LDAP::Adapter.new('ldapmain')共通名でグループを検索します。UsersLDAPGroup を検索する共通名に置き換えてください。
GitLab 8.11 以降
group = EE::Gitlab::Auth:Ldap::Group.find_by_cn('UsersLDAPGroup', adapter)GitLab < 8.10
group = Gitlab::LDAP::Group.find_by_cn('UsersLDAPGroup', adapter)
member_dnsを確認しますgroup.member_dns
bfd74782)