|
| 1 | +var userId = ['abel.tuter', 'abraham.lincoln']; //example |
| 2 | +var workItems = ['INC0009009', 'INC0009005']; |
| 3 | +/* Beginning of function*/ |
| 4 | + |
| 5 | +var gi = GlideImpersonate(); |
| 6 | +var currUser = gs.getUserID(); |
| 7 | + |
| 8 | +// If the logged in user doesn't have impersonating roles. |
| 9 | +if (!gi.canImpersonate(currUser)) { |
| 10 | + gs.info("You don't have access to impersonate"); |
| 11 | +} |
| 12 | +for (var id in userId) { |
| 13 | + var userGr = new GlideRecord('sys_user'); |
| 14 | + userGr.addQuery('user_name', userId[id]); |
| 15 | + userGr.query(); |
| 16 | + if (!userGr.hasNext()) { |
| 17 | + // If the user id mentioned is incorrect |
| 18 | + gs.print("Cannot find user from user id " + user[id] + ". Please Validate the user id"); |
| 19 | + } else if (userGr.active == 'false') { |
| 20 | + //If the persona is inactive |
| 21 | + gs.print(id + " is inactve."); |
| 22 | + } else { |
| 23 | + gi.impersonate(userGr.sys_id); |
| 24 | + // Analysis report |
| 25 | + gs.print("Access result for " + gs.getUserDisplayName + ":"); |
| 26 | + for (var item in workItems){ |
| 27 | + var taskGr = new GlideRecord('task'); |
| 28 | + taskGr.addQuery('number', workItems[item]); |
| 29 | + taskGr.query(); |
| 30 | + gs.print(workItems[item] + " Read: " + taskGr.canRead() + ", Write: " + taskGr.canWrite()); |
| 31 | + } |
| 32 | + |
| 33 | + } |
| 34 | + |
| 35 | +} |
| 36 | +// End impersonation. Impersonate back to logged in user |
| 37 | +gi.impersonate(currUser); |
0 commit comments