Moving from LDAP (simple) to LDAP Bind



I need some help in sorting out an issue with my user accounts.
I run gitea for a small team in-house, and had it working with LDAP (simple) for a long time.

I wanted to ditch creating accounts manually and pull from the security groups in Active Directory.

I have since got LDAP (Bind) to work so that it synchronizes fully with the local Active Directory.

I’m now having an issue where the original accounts username were created with FirstNameLastNameInitial (no space was allowed) but in the Active Directory it is FirstName(Space)LastName. The sync external user data did not change the username field, newer accounts are created correctly from the sync.

I am left with old accounts with usernames like JohnS and newer ones like John Smith.

So I looked through the gitea.db and noticed the user table and spotted the lower_name & name fields.
I edited this to match how the accounts had been entered by the external sync and thought great its all working.
Except when i go to the users that I changed, and click on their local repositories it comes back as an error 500.

If I revert the change back, the user repositories are working except the user account gets de-activated after running the external sync command from the dashboard.

What am I doing wrong!!