Exemple #1
0
 public static void RunWithAccountsChainPrivileges(SPList list, CodeToRunElevatedWithList codeToRunElevatedWithList)
 {
     try
     {
         RunWithSystemAccountPrivileges(list, codeToRunElevatedWithList);
     }
     catch
     {
         try
         {
             RunWithSiteAdminPrivileges(list, codeToRunElevatedWithList);
         }
         catch (Exception exception)
         {
             throw new CanNotPrivilegesElevationException(exception);
         }
     }
 }
Exemple #2
0
 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);
             }
         }
     });
 }
Exemple #3
0
 public static void RunWithSystemAccountPrivileges(SPList list, CodeToRunElevatedWithList codeToRunElevatedWithList)
 {
     RunWithSystemAccountPrivileges(list.ParentWeb.Site.ID, list.ParentWeb.ID, list.ID, list.ParentWeb.Site.Zone, codeToRunElevatedWithList);
 }
Exemple #4
0
 public static void RunWithSystemAccountPrivileges(Guid siteId, Guid webId, Guid listId, SPUrlZone urlZone, CodeToRunElevatedWithList codeToRunElevatedWithList)
 {
     RunWithoutAccessDenied(
         () =>
         RunWithUserTokenPrivilege(siteId, webId, listId, urlZone, GetSystemAccountUserToken(siteId, urlZone),
                                   codeToRunElevatedWithList));
 }
Exemple #5
0
 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);
         }
     }
 }