Skip to content

Switching the Context User

sergeyshushlyapin edited this page Nov 4, 2014 · 1 revision

You can switch the context user.

[Fact]
public void HowToSwitchContextUser()
{
  using (new Sitecore.Security.Accounts.UserSwitcher(@"extranet\John", true))
  {
    Xunit.Assert.Equal(@"extranet\John", Sitecore.Context.User.Name);
  }
}
Clone this wiki locally