It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to create users via REST api?

Steve Silverman Oct 15, 2014

Can I create a user that authenticates against a Delegated Authentication Directory via the REST api?  If so, can you provide an example using curl?

I've tried posting to /crowd/rest/usermanagement/latest/user but can't seem to get it right.

6 answers

1 vote
Caspar Krieger Atlassian Team Oct 16, 2014

Here's an example of a POST to create a user (which should work for a delegated authentication directory as with any other writable directory):

curl -i -X POST http://crowd.corp.sf/crowd/rest/usermanagement/latest/user -H'Content-type: application/json' -H'Accept: application/json' -umyappname:myapppass -d'
{
    "email": "testuser@example.com",
    "name": "test.user",
    "password": {
        "value": "testpass"
    }
}'

(you'll need to specify the real name and password for a Crowd application for the -u flag of course)

In general, Crowd uses the same entities (json or xml layout) for fetching things, updating things, and creating things, so - for example - if you can fetch a user, then that will get you 90% of the way to creating an identical user.

Steve Silverman Oct 16, 2014

Thanks Casper, I have done that but it only adds the user to the internal crowd directory. We have an internal directory and we also use Active Directory to authenticate users. We need to pre-populate the the LDAP directory for new users, otherwise they get an error on their first login attempt and need to wait until the directory syncronizes before they can login.

Caspar Krieger Atlassian Team Oct 17, 2014

Which directory the user is created in is determined by the ordering of the directories in the application definition in Crowd: the user will be created in the first directory with create user permission. This is intentional; the idea of Crowd applications is that they don't notice that they are getting users from several different directories. To ensure the user is created in a particular directory, you can either disable create user permission in the internal directory, or move the delegated auth directory to the top position in the Crowd application definition, or create a separate application in Crowd which only contains the delegated auth directory. I get the impression that you're writing a standalone script, so I recommend that last option.

0 votes
Pedro Cora Atlassian Team Oct 16, 2014

Yes, according to https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+APIs you can use Crowd's REST interface to create users.

For more details, take a look on the REST documentation at https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources#CrowdRESTResources-UserResource

;)

-- Pedro

Steve Silverman Oct 16, 2014

Pedro, thanks, I have already gone through all the documentation. I don't see where it allows you to specify which directory you want to add to. I have only been able to add to the default directory.

0 votes
Steve Silverman Oct 16, 2014

Just to clarify, I am able to add users to the Crowd Internal Directory. What I am attempting to do is to prepopulate a Delegated Directory that is connected to our company AD. Using the REST API, it does not seem to allow specification of which directory to add to, it always uses the CROWD Internal Directory.

0 votes
Ahmad Awadallah Feb 25, 2016

I know this is old but it may help others.  This link describes what JIRA user directory is used when creating/deleting users via REST API.

https://confluence.atlassian.com/jirakb/how-to-create-users-in-delegated-authentication-directory-using-jira-rest-api-779294020.html

Hope this helps.

Ahmad

Steve Silverman Feb 26, 2016

Ahmad, I appreciate the response, however I am trying to add users in crowd, which has multiple directories.  Even if the answer holds true for crowd, There is no way that I can see to re-order the directories,

As it stands, we automatically create import files with new users and then manually invoke the import users function via crowd.

Ahmad Awadallah Feb 26, 2016

OK I see your point.  

Craig Castle-Mead Community Leader May 04, 2017 • edited Feb 18, 2018

As Casper mentioned, it's due to the directory order within the application you're authenticating as to run the command.

To ensure we're explicit about which directory the users are created in, we've had to create a unique application for each directory we want to create users/groups in, and then authenticate as that application for the REST call.

CCM

0 votes
fii Jul 26, 2017

Hi ,

Is this possible with multiple users ? Does the REST API support this ?

Thanks 

I am having same problem here. Can this related to multiple users using one request ? Please update me if you get an solution.

0 votes
manish Mar 15, 2019

Hi ,

Is this possible with multiple groups can be created ? Does the REST API support this ?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Opsgenie

Handling Opsgenie Alerts

Hi everyone, welcome to the kb articles for Opsgenie FAQs. I'm one of the Technical Support Engineers for Opsgenie who will be providing weekly posts on FAQs from customers.   All alerts are ...

50 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you