Created on 04-17-201809:35 PM - edited 08-17-201907: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.