You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code Snippet : Remove all roles from an inactive user
5
+
When a user in an instance is inactive, it's a good practice to remove all roles assigned to that user. Following piece of code helps to remove all the roles from the inactive user.
6
+
~~~
7
+
var gr = new GlideRecord('sys_user_has_role');
8
+
gr.addEncodedQuery('user.active=false');
9
+
gr.query();
10
+
gr.deleteMultiple();
11
+
~~~
12
+
This piece of code can be used in scheduled jobs under scheduled script execution tab. This can be run weekly once to check the last one week inactive users and remove them from all assigned roles (if exist).
0 commit comments