- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Created on 04-17-2018 09:35 PM - edited 08-17-2019 07:45 AM
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
We can see the user is in ACTIVE State. You can use this toggle button to change the value.
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)
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.