Does it matter if I use RunWithElevatedPrivileges in SPJobDefinition?
-
10-12-2019 - |
Question
I have written a custom SPJobDefinition
. In the public override void Execute(Guid targetInstanceId)
method I am running some code which is encapsulated in SPSecurity.RunWithElevatedPrivileges
. Since the jobs are executed under the app pool account (this is a true statement, right?), what is the benefit/purpose of running it under System Account?
Solution
From msdn about SPSecurity.RunWithElevatedPrivileges
Executes the specified method with Full Control rights even if the user does not otherwise have Full Control
Jobs are executed under SharePoint timer service account. This account could have not full control permissions. It's permissions could be restricted.
OTHER TIPS
Pls refer to these discussion...I hope you will get the answer.
https://stackoverflow.com/questions/1036589/problem-in-creating-timer-job http://social.msdn.microsoft.com/Forums/sharepoint/en-US/696a640f-4b8d-44ce-a970-e05bd45c437f/timer-job-and-runwithelevatedpriviliges https://stackoverflow.com/questions/1340771/runwithelevatedprivileges-in-sharepoint-timer-jobs