Gitlab changing LDAP DN

We have upgraded our LDAP infra and introduced a new LDAP server. The LDAP has different LDAP tree. That’s why we had to modify Gitlab LDAP setting. This is quite easy, since it’s just modification of /etc/gitlab/gitlab.rb. The tricky part is uid search of current users. Gitlab stores the whole uid with the context inside the DB. So, we have to modify the records within the DB.

su - gitlab-psql
/opt/gitlab/embedded/bin/psql gitlabhq_production
UPDATE identities SET extern_uid = 'NEW LDAP UID' WHERE id = x;

I have created a dump of the table and modified all the records with:

cat dump | awk -F'[ ,=]' '{print "update identities set extern_uid = \x27uid="$4",ou=OU,ou=OU,ou=OU,dc=DC,dc=DC\x27 where id="$1";"}'