Tuesday, January 24, 2012

How to use SPSecurity.Runwithelevatedprivileges Method in Sharepoint 2010

In this post, I will explain in which scenario we need to use SPSecurity.Runwithelevatedprivileges method in sharepoint customisation.
There are many times when we need our code to perform certain functions that current logged In user does not have permission to perform. The SPSecurity class contains Runwithelevatedprivileges method that allow to run code under full control prilvileges.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
 // Code
 });
 This delegate method run with elevated rights under the Application Pool identity which has site collection administrator privileges on all site collections.

No comments:

Post a Comment