Monday, August 03, 2009

Other way of getting Elevated Web

SPUser superUser = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
string superToken = superUser.UserToken;
using (var site = new SPSite(SPContext.Current.Web.Url, superToken))

      return site.RootWeb; 
}

This function would return a web object running under the super user “SharePoint\System” (inbuilt) account

0 comments: