Impersonate Users

If you are working as a supporting partner or a developer for an EPiServer website that has gated content and permissions for logged in users, you may need to provide access to various of them and check that everything is working properly. In most of cases, users used to say “This page is not accessible”, “my account is having issues with accessing the report”, etc. To support them and resolve the issue, you may need to request the user name and password. Once the issue is fixed, you need to ask them change their password.

The impersonate users module will help developers or administrators to run the EPiServer website as other user. They will be able to experience it exactly as the end-user, which will aid in giving support when there are questions, and troubleshooting when a user reports a problem that is difficult to recreate. It could even allow an impersonator to help a user complete an order.

This administration tool does the following:

  • Allow an administrator user with the proper permissions to search for a user by various fields including username and email address.
  • Select the user which will open a new window to the front-end of the site, setting session user values and cookies.
  • Stop impersonating.
Impersonate Users
Stop impersonating

As a developer you will be able to switch features on/off if impersonating (thanks to David Knipe for the suggestion) by using these helper methods:

HttpContext.User.IsImpersonating();

HttpContext.User.GetImpersonatedUsername();

Installation

The module is available for download and installation as  NuGet package.

 PM> Install-Package Verndale.ImpersonateUsers

Build the solution and verify that the component was added correctly in the CMS, which is in the Admin View.

3 thoughts on “Impersonate Users

  1. Thanks for sharing! It looks like a very interesting module. It would be great to have an events such as “Impersonated user” and also a “IsImpersonating” context so we could switch features on/off if impersonating and also audit who and when it happens. If you want to open source/collaborate on this please get in touch.

    Like

  2. I love the idea behind this tool. Will you open the source?

    I’ve had problems with it working. The Impersonate menu item is great, but I get no results in that view. I do get the Impersonate link inside of the Admin view, but the link fails with an Object Reference error.

    Any tips for the setup that I may be missing?

    Here’s the error I receive:

    2019-04-22 15:01:37,309 [81] ERROR Verndale.ImpersonateUsers.Controllers.VerndaleImpersonateUsersController: Object reference not set to an instance of an object.
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Verndale.ImpersonateUsers.Controllers.VerndaleImpersonateUsersController.Impersonate(String user)
    System.NullReferenceException: Object reference not set to an instance of an object.
    at Verndale.ImpersonateUsers.Controllers.VerndaleImpersonateUsersController.Impersonate(String user)

    Like

    1. Hi James, make sure to update to the latest version of the package. You might also need to install the package:

      Install-Package Microsoft.AspNet.WebApi.Owin

      Also, take a look at the error messages in the log file.

      Like

Leave a comment