How Can I Enable ‘Can Update Profile’ For Multiple Users

Sam Rosenstein
2021-04-18 07:02

The purpose of this Knowledge Base article is to provide an efficient method of enabling the ‘Can Update Profile’ option for existing users.
In order to do this, we will write a script that utilizes the following Artifactory REST API calls.

  1. Get Users – returns a list of all Artifactory users
  2. Get User Details – returns the details for a specific Artifactory user
  3. Update User – update ‘profileUpdatable: true’ for each user

The general idea is to first generate a list of all of the users in the Artifactory instance. Afterwards, we will check that the user isn’t an admin. Next, we will update the user profile for each user. 

The reason we need to check that the user isn’t an admin is because the Update User call will set the default values for any unprovided properties. In this case, the admin default value is ‘false’ and all of the users. Therefore, if the call is made with admin users then their settings will be updated with the value of ‘admin:false’.

The example script is written in Python using the requests library. Please customize the script to fit your specific needs.import requests
import json
from requests.auth import HTTPBasicAuth
user_response = requests.get(ART_URL + "/api/security/users", auth=HTTPBasicAuth(USER, PASSWORD))

# Interate through all users in Artifactory
for user in user_response.json():
# check if user is admin
username = user['name']
user_details_response = requests.get(ART_URL + '/api/security/users/' + username,auth=HTTPBasicAuth(USER, PASSWORD))
isAdmin = user_details_response.json()['admin']

if not isAdmin:
# Update profileUpdatable for non-admin user
pload = json.dumps({"profileUpdatable" : "true"})
update_user_response = requests.post(ART_URL + '/api/security/users/' + username, data = pload, verify=False, auth=HTTPBasicAuth(USER, PASSWORD))
print('Updated profileUpdatable for user: ' + username)