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