I have gitlab configured with ldap, and I’d like to sync user account changes after being changed on the ldap end. Specifically I changed a user’s email address on the ldap server, but I can’t see the change or edit email on gitlab’s end.
We’ve connected GitLab to our Active Directory, then all our users logged in for the first time to GitLab, so their account were created on logon.
But, we had never entered anything in the email field of the user account in Active Directory, so GitLab created a random email user@activedirectorydomain.
When we figured that they were unable to change their email address via GitLab, I went in Active Directory and I’ve edited the email string with the proper addresses.
But GitLab never resynced the data. It looks like GitLab only resync every 1 hour user account to see if they are valid users or not, but does not sync the actual account information regarding email addresses.
I’ve had to impersonate each user and add a secondary email address in GitLab so far, and set that email for Notifications. But still, there’s a lot that secondary email can’t do.
A quick but important note. If you want to avoid waiting for users to confirm email you can add ‘user.skip_reconfirmation!’ and it will change the email instantly. For my use case I have about 100 users who have a legacy domain name.
I had to loop through a list of the email addresses and pre-populated them in a list and iterated over that list to make the changes.
sudo gitlab-rails console
emails = ['user1@example.net', 'user2@example.net']
for email in emails
user = User.find_by_email(email)
user.email = user.email.sub! 'example.net', 'example.com'
user.skip_reconfirmation!
user.save