Commit 80302a0f authored by Jacob Vosmaer's avatar Jacob Vosmaer

Limit the number of results in gitlab:ldap:check

parent 376cfc6a
...@@ -114,7 +114,8 @@ production: &base ...@@ -114,7 +114,8 @@ production: &base
# ========================== # ==========================
## LDAP settings ## 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: ldap:
enabled: false enabled: false
host: '_your_ldap_server' host: '_your_ldap_server'
......
...@@ -681,12 +681,13 @@ namespace :gitlab do ...@@ -681,12 +681,13 @@ namespace :gitlab do
end end
namespace :ldap do namespace :ldap do
task check: :environment do task :check, [:limit] => :environment do |t, args|
args.with_defaults(limit: 100)
warn_user_is_not_gitlab warn_user_is_not_gitlab
start_checking "LDAP" start_checking "LDAP"
if ldap_config.enabled if ldap_config.enabled
print_users print_users(args.limit)
else else
puts 'LDAP is disabled in config/gitlab.yml' puts 'LDAP is disabled in config/gitlab.yml'
end end
...@@ -694,9 +695,9 @@ namespace :gitlab do ...@@ -694,9 +695,9 @@ namespace :gitlab do
finished_checking "LDAP" finished_checking "LDAP"
end end
def print_users def print_users(limit)
puts 'The following LDAP users can log in to your GitLab server:' puts "LDAP users with access to your GitLab server (limit: #{limit}):"
ldap.search(attributes: attributes, filter: filter, return_result: false) do |entry| 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]}" puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}"
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment