diff options
author | Marvin Frick <marvin.frick@sinnerschrader.com> | 2014-06-26 17:38:11 +0400 |
---|---|---|
committer | Marvin Frick <marvin.frick@sinnerschrader.com> | 2014-06-26 18:09:15 +0400 |
commit | ec61dfdc8cea4c6a3e8a03790eb1c225f8562d27 (patch) | |
tree | ed54d0be780b3f849918d556428e18f958ac3bb5 /lib/tasks | |
parent | 024e0577c6b6ded30ee09536082bd24405bda1e5 (diff) |
adds rake task to clean up deleted LDAP users
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/cleanup.rake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake index 4aaab11340f..63dcdc52370 100644 --- a/lib/tasks/gitlab/cleanup.rake +++ b/lib/tasks/gitlab/cleanup.rake @@ -84,5 +84,29 @@ namespace :gitlab do puts "To cleanup this directories run this command with REMOVE=true".yellow end end + + desc "GITLAB | Cleanup | Block users that have been removed in LDAP" + task block_removed_ldap_users: :environment do + warn_user_is_not_gitlab + block_flag = ENV['BLOCK'] + + User.ldap.each do |ldap_user| + print "#{ldap_user.name} (#{ldap_user.extern_uid}) ..." + if Gitlab::LDAP::Access.open { |access| access.allowed?(ldap_user) } + puts " [OK]".green + else + if block_flag + ldap_user.block! + puts " [BLOCKED]".red + else + puts " [NOT IN LDAP]".yellow + end + end + end + + unless block_flag + puts "To block these users run this command with BLOCK=true".yellow + end + end end end |