关于MOSS 提升权限问题

在Share Point 开发过程中经常会遇到无权操作。解决的办是 提升权限。提升权限的方式也很简单。

String strurl = SPContext.Current.Site.Url;

SPSecurity.RunWithElevatedPrivileges(delegate()

{

using (SPSite mySite = new SPSite(strurl))

{

执行操作

}

});

上边代码中标红的地方需要注意。经常会犯错SPSite mySite = new SPSite(strurl)不能用SPContext.Current.Site代替,否则提升权限将不成功。不成功并没有什么警告,只是和没加这段代码一样。

原文地址:https://www.cnblogs.com/moonwebmast/p/1452806.html