Sharepoint 2010 Articles

Submit Article
Home » Articles » Sharepoint 2010 » Design and CustomizationRSS Feeds

What does RunWithElevatedPrivileges in SharePoint 2013

Posted By: Destin Joy     Category: Sharepoint 2010     Views: 4434

Assume that you have a Web Part in which you want to display information obtained through the Windows SharePoint Services object model, such as the name of the current site collection owner, usage statistics, or auditing information. These are examples of calls into the object model that require site-administration privileges. Your Web Part experiences an access-denied error if it attempts to obtain this information when the current user is not a site administrator. The request is initiated by a non-privileged user. You can still successfully make these calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class. C#:

SPSite siteColl = SPContext.Current.Site;

SPWeb site = SPContext.Current.Web;SPSecurity.RunWithElevatedPrivileges(delegate()


using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))


using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))


string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;

string Visits = ElevatedsiteColl.Usage.Visits.ToString();string RootAuditEntries = ElevatedSite.RootFolder.Audit.GetEntries().Count.ToString();




Didn't find what you were looking for? Find more on What does RunWithElevatedPrivileges in SharePoint 2013 Or get search suggestion and latest updates.

Destin Joy
Destin Joy author of What does RunWithElevatedPrivileges in SharePoint 2013 is from Pathanamthitta, India. Destin Joy says

 Hello Everyone,

I am Destin Joy from India I have MCPD in SharePoint 2010, MCTS SharePoint 2010 application development and MCTS in SharePoint 2007. I am mostly working in  core part of SharePoint (2010-2007) and passionate about new Microsoft technologies. Born and brought up in Kerala You can reach me  @ Destin.Joy@hotmail.com


View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!