I guess starting a timer job from within the code requires Farm admin credentials. However, I need to start a timer job from a web part that will be used in any site. Now when I try to start the job it gives me an access denied error obviously because the app pool identity is not farm admin. Any ideas on how to resolve this issue?
Thanks,
Timer jobs run as the farm administrator and are not intended to be triggered directly by an end-user. Since some jobs may be resource intensive, only the farm admin can create new jobs or modify the schedule for existing jobs.
One solution is to use the
SPWorkIteminfrastructure to queue user tasks which are then processed by a custom timer job derived fromSPWorkItemJobDefinition. Your webpart would callSPSite.AddWorkItemto add the work item. When your timer job runs, it will look for any work items with the matching WorkItemType GUID and invoke theProcessWorkItemoverload.