I want to allow impersonate user access to a custom role.

sunil kumar6
Tera Contributor

I want to restrict impersonate user access to users who are having a custom role impersonate_user role. I have customized this script include "ImpersonateEvaluator" as below but not working as expected

 

var ImpersonateEvaluator = Class.create();
ImpersonateEvaluator.prototype = {
initialize: function() {},
type: 'ImpersonateEvaluator',
canImpersonate: function(currentUser, impersonatedUser) {
if (currentUser.hasRole('Impersonate_user'))
return false;
else
return true;
}
};

5 REPLIES 5

SatyakiBose
Mega Sage

Hello @sunil kumar6 

For your solution please refer to this community post:

 
You need to basically perform the below steps:
 
  • You can check for impersonation through the current session and use this in your ACLs/etc. to block those certain actions.
  • For example, to return false as the answer in an ACL script when someone is using impersonation:

 

answer = !(GlideImpersonate().isImpersonating());

 

 

Here is a reference to read through: GlideImpersonateAPI