Hi,
Thank you for your message.
Why would you want to run the code in a different context? Most of Kentico API providers will take an instance of UserInfo as a parameter. You might consider getting the UserInfo you need and pass it to the methods. Im not sure what the goal of your code is.
In any case you could log out the current user by method:
CMSContext.CurrentUser.Invalidate()
and then log in the user with Authentication helper -> authenticate user method.
You can see the example here ->
http://devnet.kentico.com/docs/devguide/membership_api_examples_managing_users.htmLet me know if you need anything else.
Kind regards,
Richard Sustek