From 80302a0f6f4fcfe5adf719888f8ad67422a98d4d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 3 Dec 2013 18:51:21 +0100 Subject: [PATCH] Limit the number of results in gitlab:ldap:check --- config/gitlab.yml.example | 3 ++- lib/tasks/gitlab/check.rake | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index fd2abb9..4488bbc 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -114,7 +114,8 @@ production: &base # ========================== ## LDAP settings - # You can check your LDAP settings by running `bundle exec rake gitlab:ldap:check RAILS_ENV=production` + # You can inspect the first 100 LDAP users with login access by running: + # bundle exec rake gitlab:ldap:check[100] RAILS_ENV=production ldap: enabled: false host: '_your_ldap_server' diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 1cea4ff..20d5f03 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -681,12 +681,13 @@ namespace :gitlab do end namespace :ldap do - task check: :environment do + task :check, [:limit] => :environment do |t, args| + args.with_defaults(limit: 100) warn_user_is_not_gitlab start_checking "LDAP" if ldap_config.enabled - print_users + print_users(args.limit) else puts 'LDAP is disabled in config/gitlab.yml' end @@ -694,9 +695,9 @@ namespace :gitlab do 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| + def print_users(limit) + puts "LDAP users with access to your GitLab server (limit: #{limit}):" + ldap.search(attributes: attributes, filter: filter, size: limit, return_result: false) do |entry| puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" end end -- libgit2 0.21.2