Impersonating a user in ServiceNow lets an administrator switch their session to another user and see the platform as that person does. An administrator with the admin or impersonator role can do this in a scoped application, once the feature is visible. The start and end of each session are written to the system log.
What impersonation does
Impersonation swaps the identity of your current session for another user’s. The menus, modules and records you can reach change to match that person. A support analyst who says “I cannot see the Change module” can be checked directly: you become that user and look.
The main use is testing and troubleshooting. A role change, a new access control rule or a form change looks fine from an administrator account because administrators see so much. Impersonation shows the result from the seat of the person who has to live with it. For how those rules work, see access control lists explained.
After testing, a sensible habit is to end the impersonation, so the next piece of work starts from your own identity.
One consequence matters for anyone who relies on records for accountability. Work done during impersonation is recorded under the impersonated user, not under the person who was actually typing. The next sections cover what that means for the audit trail.
Who can impersonate
An administrator with the admin or impersonator role can impersonate a user in a scoped application. Granting either role to a person is the permission decision here, so it deserves the same care as any other elevated role. The wider topic is covered under instance security and access control. For the wider picture of who should hold which role, see roles and responsibilities for instance security.
Before anyone can use the feature, an administrator must make it visible. Until that is done the option does not appear for users.
The scripting side tells a related story. The GlideImpersonate API has a check, canImpersonate, that tells a script whether the current user may impersonate a given user. It returns true when impersonation is allowed and false when it is not. Among the conditions for that check, the current user must hold the admin role and the target must be an active user. When you design a scripted test or a scheduled job around impersonation, call that check first rather than assuming the switch will succeed.
How to impersonate a user
To start, pick a user by selecting from the recent users or by entering another user name. Impersonation ends when you switch to a different user or when the session ends, for example after logging out.
Requirements on the target user
The account you want to impersonate needs a user ID in its User record. When the user ID is blank, the message “The user you selected could not be impersonated” appears. The fix is to complete the user ID on the record.
Locked-out and inactive users are a separate case. If you impersonate one, the system logs you out as soon as you take an action or select a link. So an inactive or locked-out account is a poor test persona. Create or reactivate a test account instead.
Good testing usually needs more than one persona. A workable minimum is an administrator account for admin tasks, an ITIL-style account to test as a technician, and an end-user (ESS) account to test the self-service view.
Restrictions while impersonating
Impersonation carries limits that can surprise a tester. They are worth knowing before a test produces a confusing result.
Admin-role targets. When you impersonate a user who holds the admin role, access to certain features and modules is limited unless you already hold the same roles yourself.
Application admin roles. The same limit applies to application-specific admin roles, such as Human Resources admin or Security Incident Response. Features such as security incidents and profile information are restricted, and some modules and applications in the navigation bar are affected, unless you already hold those roles.
Passwords. Administrators cannot change the password of a user who holds an application admin role.
Scoped applications. When a scoped application is involved, the protected roles of that application are removed from the impersonated session. A system property, glide.sys.allow_scoped_user_impersonation, controls whether impersonation of scoped users is allowed. With it set to true, impersonation proceeds and the protected roles are stripped. As a practical judgement, it is a sensible first property to examine when impersonation fails for a user in a scoped application. For background, see application scope explained.
Module access policies. Access to scope-protected roles and encryption module roles during impersonation depends on the Impersonation option being set in the module access policy.
A practical reading of these limits: if a test as a privileged persona shows missing modules, the cause may be the impersonation rules above and not a defect in your configuration. Repeat the check from a login that really holds the roles in question before you raise a bug.
What gets logged
Starting an impersonation writes an Impersonate Begin event to the system log. Ending it writes an Impersonate End event. These two entries tell an auditor who stepped into another identity and when the session stopped. For the wider discipline, see audit management in ServiceNow.
Impersonation ends in two situations. It ends when the impersonator switches to a different user, and it ends when the session itself ends, for example at logout.
The GlideImpersonate API adds a scripting view of the same state. isImpersonating takes no parameters and returns true when the current user is impersonating someone. The impersonate method switches the administrator’s session to the user whose sys_id you pass in and returns the sys_id of the user who was signed in beforehand. Calling the method again with the administrator’s sys_id ends the impersonation. The method is intended for application testing, and actions taken through it are logged as the impersonated user’s, just like interface impersonation.
Turning impersonation logging on
The property glide.sys.log_impersonation controls whether events where one user impersonates another are logged on the instance. Setting it to true records all interactive sessions, meaning those started from the user interface. The recommended value is true. If it is not set to true, impersonation events stop being logged. To check it, open the sys_properties table and confirm the property exists and is true. If it does not exist, create a record for it.
Sessions that applications and scripts start are a separate case. The property glide.sys.log_impersonation.non_interactive switches logging on for those, and it is off by default. Even with it on, impersonations of the default users system, soap.guest and guest are not logged. A third property, glide.sys.log_impersonation.non_interactive.exclusion, takes a comma-separated list of user names whose non-interactive impersonations should be left out. Non-interactive impersonations are recorded in the impersonate log.
Keeping application data out of reach
Some applications can hide their data from an administrator who is impersonating a user. The control is a system property named after the application scope, in the form scope.impersonateCheck, for example sn_hr_core.impersonateCheck. Applications can have their own property.
It is a Boolean property in sys_properties. The recommended value is true and the default is false. With false, an administrator-level user who impersonates someone can reach that application’s data with the impersonated user’s access. With true, an administrator cannot impersonate a user to view that user’s data in that specific application.
Only the scoped administrator for the application can modify the property, and you enable it by creating a system property with the value true for each relevant application. Not every application is necessarily designed to work this way. The scopes that work with it include sn_hr_core, sn_jny, sn_em and sn_ecn, among others. If an administrator cannot see an application’s records while impersonating, check this property before assuming a data fault.
Why the audit trail needs care
Because records show the impersonated user as the actor, the system log entries for the start and end are the link between a record change and the person who actually made it. When a change appears on a record under a user’s name and that user denies making it, the question to ask is whether an impersonation session covered that time. Compare the timestamps of the Impersonate Begin and Impersonate End entries against the record change.
For that reason, keep impersonation access to a short list of named people, and keep a habit of ending sessions when the test is done rather than leaving them open. Related guidance is in instance security and access control best practices and security and access design.
Frequently asked questions
What role do I need to impersonate a user in ServiceNow?
An administrator with the admin or impersonator role can impersonate a user in a scoped application. An administrator must also have made the feature visible. For scripts, the canImpersonate check expects, among its conditions, the admin role and an active target user.
Why does it say the user could not be impersonated?
The selected account has no user ID in its User record. Add the user ID and try again.
Does impersonation end when I log out?
Yes. It ends when the session ends, such as at logout, and also when you impersonate a different user.
Are impersonated actions recorded under my name?
They are recorded as if the impersonated user performed them. The Impersonate Begin and Impersonate End entries in the system log mark the session, provided logging is switched on.
Why can I not impersonate a user in a scoped application?
Check the glide.sys.allow_scoped_user_impersonation property. When it is true, the user can be impersonated and the application’s protected roles are removed from the session.