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 

Impersonation can only be performed by admin users in addition to the OOB role - 'impersonator'

This validation is done at the platform level codes, and cannot be overriten.

You can read the product documentation here:

Hello @SatyakiBose 

 

I have seen some users are customizing this script as per there requirement like below

 

https://www.servicenow.com/community/itsm-forum/how-to-restrict-admin-users-impersonating-system-adm...

This community post is from 2018, and the platform has changed alot since then.

Am not sure if the same approach would work today.

ersureshbe
Giga Sage
Giga Sage

Hi, you configure the common role to access the custom table. The below screenshot is an example, a similar way uses the same for your custom table.

ersureshbe_0-1676888620121.png

 

Regards,
Suresh.