Unable to add admin role to new users

kiran115
Tera Contributor

I am facing a weird issue with my instance. I have an admin role. Suddenly what happened don't know that I am not able to add an admin role to new users and at the same time not able to remove the admin role from the existing users. Even I have checked by elevating the roles. But the same issue am facing. Can anyone know what could be the issue and how to overcome it?

8 REPLIES 8

Edward Rosario
Mega Sage
Mega Sage

You probably have to elevate your role, then try adding

Hi @Edward Rosario, I tried by elevating the role but same problem am facing.

 

 

// Replace "user_name" with the name of the user you want to remove the admin role from
var userName = "user_name";

// Get the user record
var user = new GlideRecord('sys_user');
user.addQuery('user_name', userName);
user.query();

if (user.next()) {
   // Remove the admin role from the user
   user.revokeRole('admin');
   gs.print("Admin role removed from user: " + user.name);
} else {
   gs.print("User not found.");
}

 

This is an interesting problem, See if this helps. this first retrieves the user record based on the name provided, then removes the admin role from the user using the revokeRole method. Finally, it prints a message confirming that the admin role has been removed. You can modify this code to remove other roles or apply additional logic as needed.

Bert_c1
Kilo Patron

seems to require the 'user_admin' role based on ACLs. Of course, we don't know which role is meant by "an admin role".