Update email using ldap

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.

How would I sync user profiles?

1 Like

I’m facing the same problem.

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.

Email can be updated manually from console

$ sudo gitlab-rails console
[sudo] password:
-------------------------------------------------------------------------------------
 GitLab:       11.2.3 (06cbee3)
 GitLab Shell: 8.1.1
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.find_by_email("user.name@something.com")
=> #<User id:146 @user.name>
irb(main):003:0> user.email
=> "user.name@something.com"
irb(main):004:0> user.email = "user.name@corp.domain.com"
=> "user.name@corp.domain.com"
irb(main):005:0> user.save
=> true
3 Likes

you’re a legend

1 Like

thank you @wl2776 . Also saved my ass.

1 Like

There is also a good python module for Gitlab: https://python-gitlab.readthedocs.io/en/stable/
It works using Gitlab web-API.
I use it to automate many administration tasks.

1 Like