From 9fa7364a747a2b1491bf7a3e462d4d6993af1bbb Mon Sep 17 00:00:00 2001 From: icode Date: Tue, 16 Oct 2018 12:01:44 +0000 Subject: [PATCH] support sync name from ldap close #1974 --- ee/lib/ee/gitlab/auth/ldap/access.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ee/lib/ee/gitlab/auth/ldap/access.rb b/ee/lib/ee/gitlab/auth/ldap/access.rb index 77cb4f2cda22e2..846e5cfe9fcc7c 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 -- GitLab