LDAP user conflicts

Hi, I have a Nextcloud server (17.0.3) with LDAP auth, having as source 2 samba DCs. The LDAP configuration is pretty basic, the only important change that I have is that in the expert tab I’ve set “Internal Username Attribute” to sAMAccountName so when Nextcloud did import the users, it used the actual usernames not that UUID.

The problem I’m having is that one user, let’s call it john.doe, got a duplicate named john.doe_9621. After investigating I’ve found that the original user john.doe got detected by nextcloud as deleted and appears in the list of LDAP remnants. When John Does logs in with his LDAP credentials he actually logs into john.doe_9621 now, obviously without his personal files, group ownership, shares, etc. Just like it’s a new user.

That user never got deleted from LDAP and the only change done to that LDAP user seems to be his DN. But same change was done to other users (including mine) and no problems there. Plus from what I’ve read on the nextcloud documentation a DN change is detectable and no conflicts should arise.

Does anyone know what could create this problem and how can I restore user john.doe?