Execution:

ARTIFACTORY: How to get the list of admin users in Artifactory?

AuthorFullName__c
Elina Floim
articleNumber
000005374
ft:sourceType
Salesforce
FirstPublishedDate
2022-08-17T08:38:37Z
lastModifiedDate
2022-08-17
VersionNumber
8

Use an IDE to create a python file (.py) that will contain the following script:

import json
import os

#gets the list of users
command_s = "curl -u admin:password https://$ART_HOST/artifactory/api/security/users"
command_e = " > /path/to/users.json"
request = command_s + command_e
command_exe = os.system(request)

#reads the json file containing the list of users
with open('/path/to/users.json', 'r') as fcc_file:
   user_data = json.load(fcc_file)
   values = []
   #creates a list named 'values' which contains the user names
   for i in user_data:
       values.append(i["name"])
       
#creates an empty list that will hold the admin users
admins = []
#for each user, get the user details
for name in values:
   command_s = "curl -u admin:password https://$ART_HOST/artifactory/api/security/users/"
   command_e = " > /path/to/user_result.json"
   request = command_s + name + command_e
   command_exe = os.system(request)
   with open('/path/to/user_result.json', 'r') as user_file:
       admin_data = json.load(user_file)
       #if the user is an admin, add him to the list
       for key in admin_data:
           if (key == 'admin') and admin_data[key]:
               admins.append(admin_data['name'])
print(admins)