首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharePoint安全编程问题

SharePoint安全编程问题
EN

Stack Overflow用户
提问于 2010-02-25 13:28:17
回答 1查看 1.6K关注 0票数 0

我正在使用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?幕后的原因是什么?

先谢谢你,乔治

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-25 13:40:42

执行命令的用户是否具有运行命令的权限?根据documentation,当您将该属性设置为false时,似乎是在禁用安全验证。

要获得“超级用户”权限以执行当前用户无权运行的命令,更好的方法是使用SPSecurity.RunWithElevatedPrivileges

代码语言:javascript
复制
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.
        }
    }
});
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2331842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档