November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Here is some code, I hope it will help
System.Web.Security.Membership.Provider.ValidateUser(username, password);
if (isValidUser)
{
MembershipUser mu = System.Web.Security.Membership.Provider.GetUser(username, true);
EPiServer.Security.PrincipalInfo.CurrentPrincipal = EPiServer.Security.PrincipalInfo.CreatePrincipal(username);
} else
throw new Exception( "Fail on validate user " + username );
Hi Ruwen,
Many thanks for your reply. Unfortunately that code only seems to work in EPiServer 5. I've worked around the problem for now by not requiring to change the user ID at all.
What originally motivated the problem was that I was getting AccessDenied errors when loading and saving some pages, and there is no "NoAccess" enum value in EPiServe, however using AccessControlList.NoAccess and passing that as the AccessLevel parameter allowed me to work around the problem.
Cheers,
Andy
Hi,
Does anyone know of a way to safely switch the context of the current user within a ScheduledJob on EPiServer 4.62?
We're using:
loginResult = EPiServer.Util.LoginBase.Login(username, password, false);
However, this is producing a NullReferenceException. I suspect this is being caused by a lack of HttpContext, but I don't know.
Any advice gratefully received!
Best Regards,
Andy