Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
Labels (1)
avatar
Contributor

For security reasons, sometimes we might need to deactivate the ambari users ,rather deleting.In these scenerios make the user inactive from ambari UI, however if the users are more we might need to automate it from rest API as mentioned below.

The objective is to deactivate the user "ritesh" . One of method is from UI

Go to Admin --> manage users --> users --> click on user name

68506-screen-shot-2018-04-17-at-14943-pm.png

We can see the user is in ACTIVE State. You can use this toggle button to change the value.

68508-screen-shot-2018-04-17-at-15244-pm.png

Deactivate a user from REST API.

1. If you try to curl the rest API link http://172.26.113.155:8080/api/v1/users, it will show you all the users in the ambari. To get the properties for a particular user, append the user name at the end of the API (like below)

68509-screen-shot-2018-04-17-at-15627-pm.png

If we analyze above output, we see an element "active"="true" which controls the status of that user (active/inactive)

Hence to disable the user, run this below command. Please notice that the command has argument ("Users/active":"false") for PUT method and has been extracted from above output. You can change this body to change other values like admin.

Syntax:

curl -iv -u username:password -H "X-Requested-By: ambari" -X PUT -d '{"Users/active":"new_value"}' http://ambariserver:8080/api/v1/users/user_name

For example:

curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users/active":"false"}' http://172.26.113.155:8080/api/v1/users/ritesh

Once this command is executed we can see the new updated value in CLI and UI.

68510-screen-shot-2018-04-17-at-15901-pm.png

68511-screen-shot-2018-04-17-at-15933-pm.png


screen-shot-2018-04-17-at-15244-pm.png
940 Views
0 Kudos