Explain the role of RunWithElevatedPrivileges.
- RunWithElevatedPrivileges executes code as the System account.
- This basically then means that the code that you supply as a delegate to the method, has full permissions to modify SharePoint objects in question.
- It executes the specified method with Full control rights even if the user does not otherwise have full control.
- RunWithElevatedPrivileges used with the SPSecurity.CodeToRunElevated constructor.
Syntax:public static void RunWithElevatedPrivileges(
SPSecurity.CodeToRunElevated secureCode
)
- SecureCode object can be created from any method that is parameterless and returns void.