koma75 / crowdutil

Atlassian Crowd utility cli tool
MIT License
1 stars 0 forks source link

add command to remove/disable user/group #6

Closed koma75 closed 10 years ago

koma75 commented 10 years ago

disable user (rm from all groups, deactivate, delete etc) remove group (empty group, delete group etc.)

koma75 commented 10 years ago

atlassian-crowd currently does not support updating user profiles and thus not able to activate/de-activate user. removal of user is possible.

koma75 commented 10 years ago

may need to try adding a new method to AtlassianCrowd.user class, or create the user edit feature.

koma75 commented 10 years ago

for activation/deactivation of users,

first get the JSON object of user by

METHOD GET http://applicationname:password@hostname/crowd/rest/usermanagement/1/user?username=uid Accept: application/json

which should return a JSON file like the following

{
  "expand": "attributes",
  "link": {
    "href": "http://hostname/crowd/rest/usermanagement/1/user?username=<uid>",
    "rel": "self"
  },
  "name": "<uid>",
  "password": {
    "link": {
      "href": "http://hostname/crowd/rest/usermanagement/1/user/password?username=<uid>",
      "rel": "edit"
    }
  },
  "active": true,
  "attributes": {
    "attributes": [0],
    "link": {
      "href": "http://hostname/crowd/rest/usermanagement/1/user/attribute?username=<uid>",
      "rel": "self"
    }
  },
  "first-name": "firstname",
  "last-name": "lastname",
  "display-name": "firstname lastname",
  "email": "user@example.com"
}

from the response, remove the "password" object, and set the active key to the desired value.

{
  "expand": "attributes",
  "link": {
    "href": "http://hostname/crowd/rest/usermanagement/1/user?username=<uid>",
    "rel": "self"
  },
  "name": "<uid>",
  "active": false,
  "attributes": {
    "attributes": [0],
    "link": {
      "href": "http://hostname/crowd/rest/usermanagement/1/user/attribute?username=<uid>",
      "rel": "self"
    }
  },
  "first-name": "firstname",
  "last-name": "lastname",
  "display-name": "firstname lastname",
  "email": "user@example.com"
}

and send the resulting JSON file via request to the same URL

METHOD PUT http://applicationname:password@hostname/crowd/rest/usermanagement/1/user?username=uid Accept: application/json Content-Type: application/json