No mail data is deleted. New users with same name are remapped to existing mailboxes.
I need to check about Nextcloud as the users are mapped to UUIDs…
SOGo just uses the user domain of the mailserver app.
EDIT:
As regards Nextcloud the files would need to be migrated to the new UUID of the user.
Enter Nextcloud container:
runagent -m nextcloud1 podman exec -ti nextcloud-app sh
Example of listing files of a user:
ls -l data/73fc5571-0027-4c97-b744-eb3df525900c/files/
The UUIDs are shown in the Nextcloud account settings (when logged in as admin):
So you need to get the old UUIDs before removing the LDAP user domain and then copy the files to the new UUID directory.
Finally the files need to be scanned:
runagent -m nextcloud1 occ files:scan --all
I found that there’s an app for importing/exporting users but I never tested: User migration - Apps - App Store - Nextcloud
Yes, it’s not trivial, see Nextcloud can't create share - #23 by mrmarkuz
