I'm using the API outside website context from a Console Application and am trying to change the current user context to be user #70 (a global admin) instead of default public so that operations will run in context of an admin user.
The following code snippet looks like it should affect the context user but the context user remains public.
What should I do instead?
CMSContext.Init();
UserInfo user = UserInfoProvider.GetUserInfo(70); // A global Admin
// Set context values
CurrentUserInfo cui = new CurrentUserInfo(user, true);
CMSContext.SetCurrentUser(cui);
CultureHelper.SetPreferredUICulture(cui.PreferredUICultureCode);
// This is the test ...
if (CMSContext.CurrentUser.UserID != user.UserID)
throw new Exception("failed to set user");
// Throws an error because CurrentUser is still 65 (public) instead of expected #70.