【问题标题】:Sharepoint : Access denied when editing a page (because of page layout) or list itemSharepoint:编辑页面(由于页面布局)或列表项时访问被拒绝
【发布时间】:2011-08-20 10:01:39
【问题描述】:

我以系统帐户登录,所以它可能不是“真正的访问被拒绝”! 我做了什么: - 自定义母版页 - 来自自定义内容类型的自定义页面布局(带有自定义字段)

如果我在页面布局中添加自定义字段(在 SPD 中的工具中也称为“内容字段”),当我尝试编辑来自该页面布局的页面时,我会收到拒绝访问。

因此,例如,如果我在页面布局中添加这一行,则在“asp:content”标签中: 我被拒绝访问。如果我删除它,一切都很好。 (字段“test”是来自内容类型的字段)。

有什么想法吗?

更新

嗯,我在一个空白网站上试了一下,它运行良好,所以我的网络应用程序一定有问题:(

更新 #2

看起来母版页中的这一行给了我拒绝访问:

<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Visible="false"
    PrefixHtml="&lt;tr&gt;&lt;td colspan=&quot;0&quot; id=&quot;mpdmconsole&quot; class=&quot;s2i-consolemptablerow&quot;&gt;"
    SuffixHtml="&lt;/td&gt;&lt;/tr&gt;"></SharePoint:DelegateControl>

更新 #3

我找到http://odole.wordpress.com/2009/01/30/access-denied-error-message-while-editing-properties-of-any-document-in-a-moss-document-library/

看起来类似的问题。但我们的 Sharepoint 版本具有最新更新。我将尝试使用应该修复列表的代码并发布另一个更新。

** 更新 #4**

好的...我尝试了在上面页面上找到的代码(见链接),它似乎解决了这个问题。我还没有以 100% 的速度测试该解决方案,但到目前为止,一切都很好。这是我为功能接收器制作的代码(我使用了上面链接中发布的代码):

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

using System.Xml;

namespace MyWebsite.FixAccessDenied
{
    class FixAccessDenied : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            FixWebField(SPContext.Current.Web);
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        static void FixWebField(SPWeb currentWeb)
        {

            string RenderXMLPattenAttribute = "RenderXMLUsingPattern";

            SPSite site = new SPSite(currentWeb.Url);
            SPWeb web = site.OpenWeb();

            web.AllowUnsafeUpdates = true;
            web.Update();

            SPField f = web.Fields.GetFieldByInternalName("PermMask");
            string s = f.SchemaXml;
            Console.WriteLine("schemaXml before: " + s);
            XmlDocument xd = new XmlDocument();
            xd.LoadXml(s);
            XmlElement xe = xd.DocumentElement;
            if (xe.Attributes[RenderXMLPattenAttribute] == null)
            {
                XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute);
                attr.Value = "TRUE";
                xe.Attributes.Append(attr);
            }

            string strXml = xe.OuterXml;
            Console.WriteLine("schemaXml after: " + strXml);
            f.SchemaXml = strXml;

            foreach (SPWeb sites in site.AllWebs)
            {
                FixField(sites.Url);
            }

        }

        static void FixField(string weburl)
        {
            string RenderXMLPattenAttribute = "RenderXMLUsingPattern";

            SPSite site = new SPSite(weburl);
            SPWeb web = site.OpenWeb();
            web.AllowUnsafeUpdates = true;
            web.Update();

            System.Collections.Generic.IList<Guid> guidArrayList = new System.Collections.Generic.List<Guid>();

            foreach (SPList list in web.Lists)
            {
                guidArrayList.Add(list.ID);
            }

            foreach (Guid guid in guidArrayList)
            {
                SPList list = web.Lists[guid];
                SPField f = list.Fields.GetFieldByInternalName("PermMask");
                string s = f.SchemaXml;
                Console.WriteLine("schemaXml before: " + s);
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(s);
                XmlElement xe = xd.DocumentElement;
                if (xe.Attributes[RenderXMLPattenAttribute] == null)
                {
                    XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute);
                    attr.Value = "TRUE";
                    xe.Attributes.Append(attr);
                }
                string strXml = xe.OuterXml;
                Console.WriteLine("schemaXml after: " + strXml);
                f.SchemaXml = strXml;
            }

        }

    }
}

只需将该代码作为功能接收器,并在根站点激活它,它应该循环遍历所有子站点并修复列表。

摘要

您在编辑 PAGE 或 ITEM

时收到 ACCESS DENIED

即使您以 f****in 世界的超级管理员身份登录,您仍然会收到错误消息(抱歉,我花了 3 天时间解决该错误)

对我来说,它发生在从另一个站点定义(cmp 文件)导入之后

实际上,它应该是一个已知的错误,应该从 2009 年 2 月开始修复,但看起来不是。

我上面发布的代码应该可以解决问题。

【问题讨论】:

标签: sharepoint master-pages access-denied page-layout


【解决方案1】:

尝试发布您的 MasterPage 和页面布局,这是最常见的原因。由于系统账号是godmode,所以不会报这个错误。

在 SharePoint Designer 中,您无法执行发布工作流的最后一步(批准),因此您:

SharePoint 设计器:
CheckIn => 发布主要版本,点击 OK 按钮或转到网站上的 /_catalogs/masterpage 。

然后使用上下文菜单来批准 MasterPage 和布局。

【讨论】:

  • 我已经试过了。我要从头开始再试一次:(
【解决方案2】:

一些想法:

  • 检查您的自定义页面布局和母版页中是否有任何 Web 部件未注册为安全的。
  • 您是否定义了自己的自定义字段类型,例如编写扩展 SPField 的类?如果是这样,您是否使用自定义字段控件?如果是,请检查它是否在做任何可能需要提升权限的事情。
  • 同样,检查任何包含 Web 控件的 Web 部件的编辑模式面板,这些面板可能正在尝试执行需要提升权限的操作。

【讨论】:

  • 目前我的页面布局中没有 webpart。而我的自定义字段只是内容类型中的一个新列(一个普通的HTML字段),我没有为它写任何代码
【解决方案3】:

查看我在帖子编辑中发布的代码。它解决了我的问题。

【讨论】:

    【解决方案4】:

    问题似乎是由某些版本的 SharePoint 中的 stsadm -o export 函数中的错误引起的(我让它从 2007 RTM MOSS 服务器导出)。导入伪造的导出文件会在所有 NEWLY-CREATED 列表中导致“编辑拒绝访问”问题。 Microsoft 的更高版本补丁修复了stsadm -o export,但不要修复损坏的列表;这需要类似 tinky05 的程序。

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 2016-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      相关资源
      最近更新 更多