Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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.

like image 330
ashwnacharya Avatar asked Aug 27 '09 12:08

ashwnacharya


2 Answers

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.

like image 163
dahlbyk Avatar answered Oct 21 '22 05:10

dahlbyk


They run under the account you used when running the SharePoint Products and Technologies Configuration Wizard for the first time to connect to SQl / run the Central Admin app pool under. i.e. the God account in SharePoint.

like image 39
Colin Avatar answered Oct 21 '22 04:10

Colin