Thursday, August 3, 2017

SharePoint: SPSecurity.RunWithElevatedPrivileges method

This is used to execute the specified method with Full Control rights even if the logged in user does not otherwise have Full Control.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // Your code here...
});


Note:

1.The RunWithElevatedPrivileges method can not be used within a sandbox solution 

2.The item that is actioned with elevated privileges will be executed under the web applications App pool account in IIS, which means that the modified user of the document/list item will most likely display as SYSTEM ACCOUNT.

3.If you did not want to execute the code as the App Pool account for any reason, you could alternatively use a specific user account to execute the code under by implementing the SPUserToken class.

No comments:

Post a Comment