Automatically clean LDAP user occ user: delete

I want to automate the LDAP cleanup process. With “sudo -u www-data php occ ldap: show-remnants” I can see the orphaned LDAP user objects. And with the command “sudo -u www-data php occ user: delete [user]”, individual deleted users can be permanently deleted. How can I use this command to delete all orphaned objects in one go?
Many Thanks

See here:

1 Like

Sorry for my delay. I was out of office the last days.

Thank you for your answear. With the informations inside your link I was able to solve our problem. I had to do some modifications because our nextcloud enviroment runs in a docker container;-))