sharepointsharepoint-2007mosswindows-sharepoint-servicestimer-jobs

"RunWithElevatedPrivileges" in SharePoint Timer Jobs?


Can we use SPSecurity.RunWithElevatedPrivileges in SharePoint timer jobs?

Under whose identity will the timer job run under elevated privilegs?

Any gotcha's and must know facts regarding this will also be appreciated.


Solution

  • RunWithElevatedPrivileges only works if the current thread is using impersonation, i.e. IIS. Used in other code (timer jobs, console applications, workflow, etc.) it will have no effect. Colin is correct that by default the timer service runs as the farm service account specified in the COnfiguration Wizard. You can verify this in Windows Services.