How to pull reports on inactive users with roles and group

AP30
Tera Expert

Hello,

I am looking to pull a report on inactive users that still have roles and groups assigned to them. How do i query this report? Please help with a script if it is required.

Thank you.

1 ACCEPTED SOLUTION

Dubz
Mega Sage

report on the sys_user_grmember table and filter for where user.active is true.

Best practice is to assign roles to groups and have users inherit their roles that way. If you've assigned roles directly to users you'll need to report on the sys_user_has_role table as well.

View solution in original post

8 REPLIES 8

haha. You are right about the intuition. I just wanted to share the result so you are aware. Even with a user.active = false on the sys_user_grmember table, the report is not accurate.

 

Tried sys_user table with active = false but not able to specify whether those users still have roles/groups or not.

The report will show you users who are inactive but are still a member of a group. You could refine further to say group.roles ISNOTEMPTY if you really wanted but i think just membership of a group would be enough.

It's a good idea to run some cleanup on user records when they move to inactive, a simple script like below to run after update when active changes to false can ensure you don't have inactive licensed users:

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', current.sys_id);
gr.query();

while(gr.next()){
gr.deleteRecord();
}

If your question is answered could you mark my response correct to close the thread down please?

Done. Thanks David!