提升权限

SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPUser user = site.Users[@"Moss\lijierong"];
SPUserToken userToken = user.UserToken;

SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID, userToken)) {
using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))

{ //lijierong身份运行
string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;
}
}
});

你可能感兴趣的:(权限)