ARTIFACTORY: How to update non-admin to admin user via SQL command in emergency?

David Shin
2022-09-01 12:18

When you have no access to any admin user in Artifactory (ie the employee with admin access leaves the company, or you cannot login, etc), there are two ways to create a new admin or promote non-admin to admin user with DB SQL queries.
 

Solution 1

If you can access the Artifactory machine, you can re-create an admin user this way by recreating the admin user.
 

Solution 2

However, if you can't access the Artifactory machine.  You can't use the above way.

However, if you can access the DB directly or get help from your DBA, you can promote a non-admin user to the admin user by the following.

First, get the user_id with an internal username by running the following SQL query:   select user_id from access_users where username='<User Name>';
Second, check if there is an artifactory_admin prop_key that exists by running the following SQL query:   select user_id, prop_key, prop_value from access_users_custom_data where user_id=<user_id_from_step1>;
Note: If you can not see the artifactory_admin prop_key, you need to insert the value by running this: insert access_users_custom_data (user_id, prop_key, prop_value, prop_sensitive, prop_cluster_local) values (<user_id_from_step1>, 'artifactory_admin','true',0,0);
  If you can see the artifactory_admin prop_key and false value in prop_value column, you need to  update the false to true by running the following:   update access_users_custom_data set prop_value='true' where user_id=<user_id_from_step1> and prop_key='artifactory_admin';