diff --git a/Server-Side Components/Background Scripts/Access Analysis Utility/Access alaysis script.js b/Server-Side Components/Background Scripts/Access Analysis Utility/Access alaysis script.js new file mode 100644 index 0000000000..a208b08d30 --- /dev/null +++ b/Server-Side Components/Background Scripts/Access Analysis Utility/Access alaysis script.js @@ -0,0 +1,37 @@ +var userId = ['abel.tuter', 'abraham.lincoln']; //example +var workItems = ['INC0009009', 'INC0009005']; +/* Beginning of function*/ + +var gi = GlideImpersonate(); +var currUser = gs.getUserID(); + +// If the logged in user doesn't have impersonating roles. +if (!gi.canImpersonate(currUser)) { + gs.info("You don't have access to impersonate"); +} +for (var id in userId) { + var userGr = new GlideRecord('sys_user'); + userGr.addQuery('user_name', userId[id]); + userGr.query(); + if (!userGr.hasNext()) { + // If the user id mentioned is incorrect + gs.print("Cannot find user from user id " + user[id] + ". Please Validate the user id"); + } else if (userGr.active == 'false') { + //If the persona is inactive + gs.print(id + " is inactve."); + } else { + gi.impersonate(userGr.sys_id); + // Analysis report + gs.print("Access result for " + gs.getUserDisplayName + ":"); + for (var item in workItems){ + var taskGr = new GlideRecord('task'); + taskGr.addQuery('number', workItems[item]); + taskGr.query(); + gs.print(workItems[item] + " Read: " + taskGr.canRead() + ", Write: " + taskGr.canWrite()); + } + + } + +} +// End impersonation. Impersonate back to logged in user +gi.impersonate(currUser); diff --git a/Server-Side Components/Background Scripts/Access Analysis Utility/Access report example.png b/Server-Side Components/Background Scripts/Access Analysis Utility/Access report example.png new file mode 100644 index 0000000000..53e847344b Binary files /dev/null and b/Server-Side Components/Background Scripts/Access Analysis Utility/Access report example.png differ diff --git a/Server-Side Components/Background Scripts/Access Analysis Utility/README.md b/Server-Side Components/Background Scripts/Access Analysis Utility/README.md new file mode 100644 index 0000000000..00cc8f4b28 --- /dev/null +++ b/Server-Side Components/Background Scripts/Access Analysis Utility/README.md @@ -0,0 +1,5 @@ +In scenarios where it's necessary to verify Read/Write access for multiple users across various work items (such as Incidents, Tasks, etc.), traditional methods like impersonating individual users or using the Access Analyzer plugin can be time-consuming. This utility streamlines the process by enabling simultaneous access analysis for multiple users by impersonating them and can be executed efficiently via a background script. + +userId- Array containing the user id of personas whose access to be analyzed. + +workItems- Work items extending the 'task' table.