コード例 #1
0
 public static void RunWithAccountsChainPrivileges(SPListItem listItem, CodeToRunElevatedWithItem codeToRunElevatedWithItem)
 {
     try
     {
         RunWithSystemAccountPrivileges(listItem, codeToRunElevatedWithItem);
     }
     catch
     {
         try
         {
             RunWithSiteAdminPrivileges(listItem, codeToRunElevatedWithItem);
         }
         catch (Exception exception)
         {
             throw new CanNotPrivilegesElevationException(exception);
         }
     }
 }
コード例 #2
0
 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);
             }
         }
     });
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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));
 }
コード例 #5
0
 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);
         }
     }
 }