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