Change user backend from IMAP to Database (native)

Hi, this is a short guide on how to “convert” an external user (IMAP in my case but should probably work for any user_external backend) to a Nextcloud-native (internal database) user.

  1. delete the user from users_external table:
delete from user_external where uid='<user_uid>';
  1. create the user in users table without password:
insert into users values('<uid>','<display_name>','','<uid_lowercase');
  1. reset user’s password
$ occ user:resetpassword <uid>

This works for me on a small-scale deployment (tens of users, mixed internal and IMAP) on Nextcloud 24.0.5.

I didn’t test everything yet (shares, apps, etc.) but the user can login and all auth tokens seems to be preserved. E2E is not enabled!

You should be able to create the user with a password as well, you just need the proper hash to insert to the users table. Not tested though.

ymmv, always test first and backup!