public static void RunWithAccountsChainPrivileges(SPList list, CodeToRunElevatedWithList codeToRunElevatedWithList) { try { RunWithSystemAccountPrivileges(list, codeToRunElevatedWithList); } catch { try { RunWithSiteAdminPrivileges(list, codeToRunElevatedWithList); } catch (Exception exception) { throw new CanNotPrivilegesElevationException(exception); } } }
private static void RunWithUserTokenPrivilege(Guid siteId, Guid webId, Guid listId, SPUrlZone urlZone, SPUserToken userToken, CodeToRunElevatedWithList codeToRunElevatedWithList) { RunWithoutAccessDenied(() => { using (SPSite site = new SPSite(siteId, urlZone, userToken)) { using (SPWeb web = site.OpenWeb(webId)) { SPList list = web.Lists[listId]; codeToRunElevatedWithList(list); } } }); }
public static void RunWithSystemAccountPrivileges(SPList list, CodeToRunElevatedWithList codeToRunElevatedWithList) { RunWithSystemAccountPrivileges(list.ParentWeb.Site.ID, list.ParentWeb.ID, list.ID, list.ParentWeb.Site.Zone, codeToRunElevatedWithList); }
public static void RunWithSystemAccountPrivileges(Guid siteId, Guid webId, Guid listId, SPUrlZone urlZone, CodeToRunElevatedWithList codeToRunElevatedWithList) { RunWithoutAccessDenied( () => RunWithUserTokenPrivilege(siteId, webId, listId, urlZone, GetSystemAccountUserToken(siteId, urlZone), codeToRunElevatedWithList)); }
public static void RunWithAccountsChainPrivileges(Guid siteId, Guid webId, Guid listId, SPUrlZone urlZone, CodeToRunElevatedWithList codeToRunElevatedWithList) { try { RunWithSystemAccountPrivileges(siteId, webId, listId, urlZone, codeToRunElevatedWithList); } catch { try { RunWithSiteAdminPrivileges(siteId, webId, listId, urlZone, codeToRunElevatedWithList); } catch (Exception exception) { throw new CanNotPrivilegesElevationException(exception); } } }