我正在使用SharePoint Server2007企业版和Windows Server2008企业版。我已经部署了一个发布门户。我正在使用VSTS2008+ C# + .Net 3.5 + ASP.Net + SharePoint Server2007SDK开发一个ASP.Net web应用程序。
我发现有时我们需要使用SPWebApplication.FormDigestSettings.Enabled = false来遍历,例如使用SharePoint应用程序接口在网站集中创建一个网站。我想知道为什么我们需要执行SPWebApplication.FormDigestSettings.Enabled = false?幕后的原因是什么?
先谢谢你,乔治
发布于 2010-02-25 13:40:42
执行命令的用户是否具有运行命令的权限?根据documentation,当您将该属性设置为false时,似乎是在禁用安全验证。
要获得“超级用户”权限以执行当前用户无权运行的命令,更好的方法是使用SPSecurity.RunWithElevatedPrivileges
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// Note: It's important that you create all new SPSite and SPWeb
// objects in the elevated context in order to actually use elevated
// privileges. Failure to do so will cause your code to execute
// without elevated privileges.
using(SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using(SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
{
// run code here that requires elevated privileges.
}
}
});https://stackoverflow.com/questions/2331842
复制相似问题