Stop admin impersonation

Kirtiman
Tera Contributor

How can i stop admins to restrict impersonation of other admins.Tried multuple codes but its not working flawlessly.

 

Tried modifying "ImpersonateEvaluator" out f box script include but it didn't work. I have used the accepted solutions from cmmunity as well.But this seems to not working in my PDI as well.

 

Below is the code.

 

Any help will be appreciated.

 

var ImpersonateEvaluator = Class.create();
ImpersonateEvaluator.prototype = {
initialize: function() {
},
BLOCKED_ROLES: [
'admin' //the EXACT names of the roles to block
],
canImpersonate: function(currentUser, impersonatedUser) {
var i,
currentUserRoles = currentUser.getRoles(),
impersonatedUserRoles = impersonatedUser.getRoles();
//Iterate over array of roles that cannot be impersonated.
for (i = 0; i < this.BLOCKED_ROLES.length; i++) {
if (currentUserRoles.indexOf(this.BLOCKED_ROLES[i]) < 0 && impersonatedUserRoles.indexOf(this.BLOCKED_ROLES[i]) >= 0) {
gs.warn('Unable to impersonate user ' + impersonatedUser.getID() +
', as the role ' + this.BLOCKED_ROLES[i] + ' was not possessed by the impersonator: ' +
currentUser.getID());
return false;
}
}
//Otherwise, return true
return true;
},
type: 'ImpersonateEvaluator'
};

 

8 REPLIES 8

This will work fine here to restrict current admin to impersonate any other admin however when current admin impersonate other user(except admin) and then click on "End Impersonation" the session doesn't end's impersonation to come back with current logged in user's(admin) id and the impersonated users screen in retained.

 

Steps:

Implement your code(as admin)

Impersonate an admin(restricts that's ideal)

Impersonate some other users except admin(impersonated that ideal)

Click on "End Impersonation" button (Doesn't work 😞 )

 

Please check this in your PDI and if you know any fix for this kindly assist.

Anil Shewale
Mega Guru

Sorry doesn't help

Did you find a solution to this issue?