How to limit users in impersonation

Community Alums
Not applicable

Hi Team, how can we limit the users to be selected in impersonation window? We have a requirement to allow only approved users to be available for impersonators to impersonate.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Thank you @iamkalai, I have used below condition in before query BR on sys_user table, and it works.

Condition: gs.getSession().isInteractive()  && gs.action != ''

Script: if ((gs.action.getGlideURI().toString()).indexOf('impersonate') != -1 || (gs.action.getGlideURI().toString()).indexOf('angular.do?sysparm_type=ref_list_data') != -1) {

  <YOUR CODE GOES HERE>

}

 

NOTE: Do not add above if condition in the condition field, orelse you will get java null pointer exception while updating record in sys_user table.

View solution in original post

17 REPLIES 17

p t1
Kilo Sage
Kilo Sage

Hi,

https://community.servicenow.com/community?id=community_question&sys_id=7721dbe9dbdcdbc01dcaf3231f9619da

 

try with this link..

Community Alums
Not applicable

Thank you Preethi, I am currently using the script include. But this is not what I want.

I want to limit the selection of the user in impersonation window itself.

Impersonator should view only limited users in the impersonation selection window.

Hello Vikas,

Quick easy way ( not the best solution ) but f you can customize the ui macro , you can modify : sys_ui_macro.do?sys_id=1bf0cfd0eb1321001c13abf11206fee4 - impersonate_dialog ui macro

line 24 - 37

<j:if test="${actual_user.hasRole('admin')}">
   <j:set var="jvar_impersonate_query" value="QUERY:active=true^locked_out=false^web_service_access_only=false^ORweb_service_access_onlyISEMPTY" />
  </j:if>
  <j:if test="${!actual_user.hasRole('admin')}">
   <j:set var="jvar_impersonate_query" value="QUERY:active=true^locked_out=false^web_service_access_only=false^ORweb_service_access_onlyISEMPTY^roles!=admin" />
  </j:if>
  <input id="impersonate_query" type="hidden" value="${jvar_impersonate_query}" /><br/>

  <label for="${jvar_impersonate_query}" class="sr-only">
   ${gs.getMessage('Search for user')}
  </label>
  <g:ui_reference name="${jvar_impersonate_query}" table="sys_user" onchange="clearSelect()"/>
 </div>

 

 

 

 

I tried modifying the query form what you gave but doesn't changed anything...