I have a custom timer job which is scheduled to run during specific time period.
I want to give a Run Now
functionality using button click from custom sharepoint webpart. If i run timer job using a farm admin account using the code below everything works fine but any other sharepoint user with non farm account gets Access Denied issue.
var traceJob = (from jobDefinition in MainWebApp.JobDefinitions
where jobDefinition.DisplayName == "Sync Timer Job"
select jobDefinition).SingleOrDefault();
if (traceJob != null)
{
traceJob.RunNow();
}
RunWithElevatedPrivilages
neither impersonation was of any help. Can anyone help me please. How do i allow normal sharepoint users to execute the above code.