Commit 80302a0f6f4fcfe5adf719888f8ad67422a98d4d
1 parent
376cfc6a
Exists in
master
and in
4 other branches
Limit the number of results in gitlab:ldap:check
Showing
2 changed files
with
8 additions
and
6 deletions
Show diff stats
config/gitlab.yml.example
| ... | ... | @@ -114,7 +114,8 @@ production: &base |
| 114 | 114 | # ========================== |
| 115 | 115 | |
| 116 | 116 | ## LDAP settings |
| 117 | - # You can check your LDAP settings by running `bundle exec rake gitlab:ldap:check RAILS_ENV=production` | |
| 117 | + # You can inspect the first 100 LDAP users with login access by running: | |
| 118 | + # bundle exec rake gitlab:ldap:check[100] RAILS_ENV=production | |
| 118 | 119 | ldap: |
| 119 | 120 | enabled: false |
| 120 | 121 | host: '_your_ldap_server' | ... | ... |
lib/tasks/gitlab/check.rake
| ... | ... | @@ -681,12 +681,13 @@ namespace :gitlab do |
| 681 | 681 | end |
| 682 | 682 | |
| 683 | 683 | namespace :ldap do |
| 684 | - task check: :environment do | |
| 684 | + task :check, [:limit] => :environment do |t, args| | |
| 685 | + args.with_defaults(limit: 100) | |
| 685 | 686 | warn_user_is_not_gitlab |
| 686 | 687 | start_checking "LDAP" |
| 687 | 688 | |
| 688 | 689 | if ldap_config.enabled |
| 689 | - print_users | |
| 690 | + print_users(args.limit) | |
| 690 | 691 | else |
| 691 | 692 | puts 'LDAP is disabled in config/gitlab.yml' |
| 692 | 693 | end |
| ... | ... | @@ -694,9 +695,9 @@ namespace :gitlab do |
| 694 | 695 | finished_checking "LDAP" |
| 695 | 696 | end |
| 696 | 697 | |
| 697 | - def print_users | |
| 698 | - puts 'The following LDAP users can log in to your GitLab server:' | |
| 699 | - ldap.search(attributes: attributes, filter: filter, return_result: false) do |entry| | |
| 698 | + def print_users(limit) | |
| 699 | + puts "LDAP users with access to your GitLab server (limit: #{limit}):" | |
| 700 | + ldap.search(attributes: attributes, filter: filter, size: limit, return_result: false) do |entry| | |
| 700 | 701 | puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" |
| 701 | 702 | end |
| 702 | 703 | end | ... | ... |