How to create users in Delegated Authentication directory using JIRA REST API
The JIRA REST API can be used to create users as per described here: https://docs.atlassian.com/jira/REST/latest/#d2e3697 However, the directory to create users in cannot be specified directly in the POST. We can workaround this by switching directory positions or disabling directories to ensure that JIRA creates the user in the correct directory that we want, as described below.
JIRA will try to create the user in the top-most and enabled directory.
Note that the REST API can only create users in the Default JIRA Internal Directory, or Internal Directory with Delegated Authentication
- To check the position of your directories, go to
Administration >> User Management >> User Directories
- Move the directory that you want users to be created in to the top-most position, OR
- Disable the top directories and leave only the directory where you want users to be created in enabled.
Assume that you have 3 directories, in the following order:
- Delegated Auth A - Enabled
- Default Internal Directory - Enabled
- Delegated Auth B - Disabled
To add users to Delegated Auth B you can either disable 1 and 2 and then re-enable 3, or move 3 to the top-most position and re-enable it. After this, run the REST API and it should create the users in 3.
To add users in Delegated Auth A, simply run the REST API, no changes are needed.
To add users in Default Internal Directory, move it to the top-most position OR disable 1.
Changing directory order is further described in https://confluence.atlassian.com/jira/managing-multiple-directories-229838552.html