public static void RunWithAccountsChainPrivileges(SPSite site, CodeToRunElevatedWithSite codeToRunElevatedWithSite) { try { RunWithSystemAccountPrivileges(site, codeToRunElevatedWithSite); } catch { try { RunWithSiteAdminPrivileges(site, codeToRunElevatedWithSite); } catch (Exception exception) { throw new CanNotPrivilegesElevationException(exception); } } }
public static void RunWithSystemAccountPrivileges(Guid siteId, SPUrlZone urlZone, CodeToRunElevatedWithSite codeToRunElevatedWithSite) { RunWithoutAccessDenied( () => RunWithUserTokenPrivilege(siteId, urlZone, GetSystemAccountUserToken(siteId, urlZone), codeToRunElevatedWithSite)); }
private static void RunWithUserTokenPrivilege(Guid siteId, SPUrlZone urlZone, SPUserToken userToken, CodeToRunElevatedWithSite codeToRunElevatedWithSite) { RunWithoutAccessDenied(() => { using (SPSite site = new SPSite(siteId, urlZone, userToken)) { codeToRunElevatedWithSite(site); } }); }
public static void RunWithSystemAccountPrivileges(SPSite site, CodeToRunElevatedWithSite codeToRunElevatedWithSite) { RunWithSystemAccountPrivileges(site.ID, site.Zone, codeToRunElevatedWithSite); }