The usermanager utility is a great way to manage users on Posit Connect. This utility is installed with the product, and is explored in further detail here:
https://docs.posit.co/connect/admin/appendix/cli/#usermanager
Problem
There may be some instances where operations may fail, such as when attempting to rename a user, for example. In those instances, you may see an error similar to the below:
Error Running Command: The requested username is already in use. Usernames are case sensitive. Please ensure you are using the correct case.
Solution
For example, we wish to rename user1 to user2. However, we run the error mentioned above. To use the usermanager utility, we will need to stop the Posit Connect service:
sudo systemctl stop rstudio-connect
In this scenario, and despite what the error says, the user may not appear when you run a usermanager list:
sudo /opt/rstudio-connect/bin/usermanager list
The usermanager list command only lists users who are unlocked. You will need to add the --include-locked flag as below to see the clash:
sudo /opt/rstudio-connect/bin/usermanager list --include-locked
This will show the locked user whose name may potentially clash with the name that you're attempting to change. From here, we can assume that the locked user still owns content. This may not always be the case, however, it's a good measure to transfer this to the current user as a precautionary measure:
sudo /opt/rstudio-connect/bin/usermanager transfer --source-username user2 --target-username user1
In this command, user2 is the name of the existing (locked) user, and user1 is the name of the current user whose name you wish to eventually change. Once all of the content is transferred using the command above, the locked user can be deleted:
sudo /opt/rstudio-connect/bin/usermanager delete --username user2
Lastly, you can rename the user which should work as expected.
sudo /opt/rstudio-connect/bin/usermanager alter --username user1 --new-username user2
Remember to start the Connect service again:
sudo systemctl start rstudio-connect