How to Deactivate/Activate a User Through API

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

This article describes how to make an API call activate/deactivate specific user within Crowd.

Solution

Here we have a documentation related to the Crowd REST API and JSON Requests and Responses. Take a look at it to get an overview of how Crowd works with its REST API.

Here's the call we need to run based on this URL structure: http://host:port/context/rest/api-name/api-version/resource-name

 

API Call
curl -i -u <application_username>:<application_password> -X PUT --data '{"name":"<username_of_the_user>", "active":"<true/false>"}' <crowd_base_url>/crowd/rest/usermanagement/1/user?username=<username_of_the_user> --header 'Content-Type: application/json' --header 'Accept: application/json'

Please note that the PUT operation on the usermanagement/1/user REST endpoint will modify other user properties such as: user email, last name, first name and display name.

In order to prevent that you should also provide values of those fields before calling this endpoint.

API Call
curl -i -u <application_username>:<application_password> -X PUT --data '{ "name": "<username_of_the_user>",  "active": "<true/false>",  "first-name": "<first_name_of_the_user>",  "last-name": "<last_name_of_the_user>",  "display-name": "<display_name_of_the_user>",  "email": "<email_of_the_user>"}' <crowd_base_url>/crowd/rest/usermanagement/1/user?username=<username_of_the_user> --header 'Content-Type: application/json' --header 'Accept: application/json'

In order to get those values please run GET command as follows:

API Call
curl -i -u <application_username>:<application_password> -X GET <crowd_base_url>/crowd/rest/usermanagement/1/user?username=<username_of_the_user> --header 'Content-Type: application/json' --header 'Accept: application/json'

Here's an example considering:

The username and password are not your Crowd credentials but rather your Crowd application credentials. Only applications can connect to Crowd REST services and not individual users.

 

  1. Application username: crowd 
  2. Application password: test
  3. username_of_the_user: testuser
  4. Status: Deactivate
  5. crowd_base_url: https://yourcompany.com

 

Example
curl -i -u crowd:test -X PUT --data '{"name":"testuser", "active":"false"}' https://yourcompany.com/crowd/rest/usermanagement/1/user?username=testuser --header 'Content-Type: application/json' --header 'Accept: application/json'

Last modified on Jun 12, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.