SPSecurity.CodeToRunElevated Delegate
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

SPSecurity.CodeToRunElevated Delegate

Windows SharePoint Services 3

Represents methods that are passed to RunWithElevatedPrivileges, so that the methods can run with Full Control privileges even if the current user does not otherwise have Full Control.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public delegate void CodeToRunElevated()

In this example, GetSitesAndGroups is a method without parameters that returns void and is defined somewhere that is accessible to the Button1_Click method.

[C#]

protected void Button1_Click(object sender, EventArgs e)
{
   SPSecurity.CodeToRunElevated elevatedGetSitesAndGroups = new SPSecurity.CodeToRunElevated(GetSitesAndGroups);
   SPSecurity.RunWithElevatedPrivileges(elevatedGetSitesAndGroups);
}
Show:
© 2016 Microsoft