diff --git a/ee/lib/ee/gitlab/auth/ldap/access.rb b/ee/lib/ee/gitlab/auth/ldap/access.rb index 77cb4f2cda22e210ecb424ae455e5e79a764493e..846e5cfe9fcc7cd61d14ef5345de7d359b893d4f 100644 --- a/ee/lib/ee/gitlab/auth/ldap/access.rb +++ b/ee/lib/ee/gitlab/auth/ldap/access.rb @@ -11,6 +11,7 @@ def update_user return if ::Gitlab::Database.read_only? update_email + update_name update_memberships update_identity update_ssh_keys if sync_ssh_keys? @@ -99,7 +100,20 @@ def update_email user.skip_reconfirmation! end end + + # Update name if it changed in LDAP + def update_name + return false unless ldap_user.try(:name) + ldap_name = ldap_user.name + + return false if user.name == ldap_name + + ::Users::UpdateService.new(user, user: user, name: ldap_name).execute do |user| + user.skip_reconfirmation! + end + end + def update_identity return if ldap_user.dn.empty? || ldap_user.dn == ldap_identity.extern_uid