【问题标题】:Sharepoint access to list ignore user permissionSharepoint 访问列表忽略用户权限
【发布时间】:2011-06-20 12:50:15
【问题描述】:

我创建了 Web 部件(类似于向导)并且需要更改列表中的项目值,但是当获取列表项时,他们没有项目(登录的用户无权访问此列表)。我可以忽略共享点权限并更新此值吗?

我使用 LINQ 来共享点并获取上下文:

using (SystemOcenContextDataContext ctx = new SystemOcenContextDataContext("http://sh2010/sites/270"))
{
    // code :)
}

更新:

获取列表时进行测试:

  SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite ElevatedSite = new SPSite("http://sh2010/sites/270"))
                {
                    using (SPWeb ElevatedWeb = ElevatedSite.OpenWeb())
                    {
                        list = ElevatedWeb.Lists["Ankiety i oceny"];
                    }
                }
            });

对象列表“拥有”项

但在我的项目中,我在使用时使用了 sharepoint linq datacontext:

 SPSecurity.RunWithElevatedPrivileges(delegate()
            {

            using (SystemOcenContextDataContext ctx = new SystemOcenContextDataContext("http://sh2010/sites/270"))
            {
                item = ctx.AnkietyIOceny.First();
            }

        });

context(ctx) 没有任何项目:/

有什么想法吗?

【问题讨论】:

    标签: c# visual-studio sharepoint web-parts


    【解决方案1】:
      SPSecurity.RunWithElevatedPrivileges(delegate()
      {
            // Pur your code here.
      }); 
    

    了解更多详情Here

    【讨论】:

      【解决方案2】:

      SharePoint linq 提供不适用于 ElevatedPrivileges。它访问 SPWeb.Current 实例,该实例将具有请求的访问权限,而不是提升的用户。

      http://jcapka.blogspot.com/2010/05/making-linq-to-sharepoint-work-for.html

      有一种解决方法,我已经实现了大致相同的东西。这是一个很大的尴尬,但据我所知它是有效的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-02
        • 2012-01-08
        • 2010-11-07
        • 1970-01-01
        • 2017-11-12
        • 1970-01-01
        • 2017-04-23
        相关资源
        最近更新 更多