-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
In case anyone needs this, I've modified the script to run on GitLab 10. Such as lifesaver, thanks!:
namespace :gitlab do
namespace :jd do
desc 'GitLab | jd | update LDAP users DN (use UPDATE_DN="yes" to actualy do it)'
task update_ldap_dn: :environment do
update_dn = ENV['UPDATE_DN']
adapter = Gitlab::LDAP::Adapter.new("ldapmain")
User.find_each do |user|
if user.ldap_user? && user.active?
print "User (#{user.username} / #{user.email}): "
# change the first argument to whatever your email attribute is named in your AD/LDAP server
ad_identity = adapter.user("mail", user.email)
unless ad_identity.nil?
unless (ad_identity.dn == user.ldap_identity.extern_uid)
user.ldap_identity.extern_uid = ad_identity.dn
puts "[WARNING]".color(:yellow)
puts user.ldap_identity.extern_uid_change
if update_dn == 'yes'
user.ldap_identity.save!
puts "[Updated]".color(:green)
end
else
puts "[OK]".color(:green)
end
end
end
end
end
end
endMetadata
Metadata
Assignees
Labels
No labels