Vulnerability in EPiServer.Forms
I am using episerver Scheduled job when ever it runs automatically it throws exception "Object Refrence not set to an instance of an object". in my program i am using "(WindowsIdentity)HttpContext.Current.User.Identity;" any idea how to resolve this issue.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);req.UseDefaultCredentials = true;
to get an episerver page . please reply
You cannot use HttpContext.Current when it runs automatically, cause you don't have one. You have to use another approach. A setting or something to choose which account to impersonate.
You can programmatically set the user by calling:
PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal("userName");
How to set it??? I mean if the username willbe of the system where we are running the application????? or we can add Active directory User????
In that case you can configure the schedular service to run under another account instead. See http://www.windowsecurity.com/articles/controlling-windows-services-service-accounts.html.
Can we set a set a user identity and then impersonate it??????if yes please help how it can be done????