How to Deactivate/Activate a User Through API

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

目的

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

ソリューション

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

 

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'

最終更新日 2017 年 6 月 12 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.