diff options
| author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2013-11-28 15:20:40 +0100 |
|---|---|---|
| committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2013-11-28 15:20:40 +0100 |
| commit | 9f4909faadcd3aa9bf85cd2bbf5bdb0c1eecf385 (patch) | |
| tree | 79157857c87ae96c3840e9715271a4c86ae43407 /lib | |
| parent | 038b3049e8f64a913ea14525bc44c385c3141836 (diff) | |
| download | gitlab-ce-9f4909faadcd3aa9bf85cd2bbf5bdb0c1eecf385.tar.gz | |
Add LDAP check to rake gitlab:check
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tasks/gitlab/check.rake | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index f2349ca8c13..5f6856a63e3 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -3,6 +3,7 @@ namespace :gitlab do task check: %w{gitlab:env:check gitlab:gitlab_shell:check gitlab:sidekiq:check + gitlab:ldap:check gitlab:app:check} @@ -679,6 +680,41 @@ namespace :gitlab do end end + namespace :ldap do + task check: :environment do + next unless ldap_config.enabled + + warn_user_is_not_gitlab + start_checking "LDAP" + + print_users + + finished_checking "LDAP" + end + + def print_users + puts 'The following LDAP users can log in to your GitLab server:' + ldap.search(attributes: attributes, filter: filter, return_result: false) do |entry| + puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" + end + end + + def attributes + [ldap_config.uid] + end + + def filter + Net::LDAP::Filter.present?(ldap_config.uid) + end + + def ldap + @ldap ||= OmniAuth::LDAP::Adaptor.new(ldap_config).connection + end + + def ldap_config + @ldap_config ||= Gitlab.config.ldap + end + end # Helper methods ########################## |
