Support Questions
Find answers, ask questions, and share your expertise

Rest api to get ranger policy for a particular user

Hi,

I want to fetch policy details of a particular user using rest api . I do want to get policies and then corresponding users to this , but in reverse way.

curl -u admin:admin -X GET http://<Ranger_hsot>:6080/service/public/api/policy

I have executed above rest api but it details policies and its all information but I wanted to get policy corresponding to user .

Basically if I pass user id or its name then when rest api is executed it should details its corresponding policy.

could some one please refer some rest api to achieve above requirement ?

4 REPLIES 4

Same question

@Anjali Shevadkar

@Anurag Mishra

What about search a policy by username:

https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.4/bk_security/content/ranger_rest_api_policy_...

service/public/api/policy?userName=anurag

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

Best solution , it works. Thank you Anurag.

New Contributor

In Apache Ranger 0.6 the path is:

url = http://<rangerHost>:<rangerPort>/service/public/v2/api/service/<YourServiceName>/policy/user=<YourUs...;

If you want to get the result on a pretty json format you can do:

curl -u admin:admin -XGET $url | python -mjson.tool > output.json