User from ldap connection not paired with the one from user_saml

So i have a Nextcloud 12 server that has an ldap connection (using the user_ldap app) for authenticating users. With the user_saml app using an environment variable i configured nextcloud to use a CAS server (which uses the same LDAP server) to authenticate users, but when i login with the same user as before, nextcloud create another internal account instead of paring it with the existing one.

Here is an example, the first one is from the ldap connection and the second one from user_saml (these should be the same user):

I thought that if i modify the ldap connection so it would use the username instead of the uid, nextcloud would successfully pair the users. But not only nextcloud did not pair the users


To change the ldap connection to use the username instead of the uid i had to remap the users which created new data directories without the previously uploaded files.

My question is how can i make the transition from user_ldap to user_saml without the users to lose the files uploaded until now?

Update: I managed to pair the users, but i still have the problem that after i modified the ldap connection and re-maped the users i lost the files uploaded until now. They are still stored in the data directory under the old username(uid), is there a way to import the files from the old data dir to the new one (just moving them from command line doesn’t work since i guess the paths of the files are stored in the DB)?