- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2019 06:49 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2019 06:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2019 07:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2019 07:43 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 12:49 AM
If your question is answered could you mark my response correct to close the thread down please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 08:33 AM
Done. Thanks David!