Sharepoint:编辑页面(由于页面布局)或列表项时拒绝访问

时间:2010-01-14 15:03:50

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

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

如果我在页面布局中添加自定义字段(在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 时,您会收到拒绝访问

即使你是以世界f ****的超级管理员身份登录,你仍然会收到错误(抱歉,我花了3天时间来处理该错误)

对我来说,它发生在从另一个网站定义(cmp文件)

导入之后

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

我上面发布的代码应该解决这个问题。

4 个答案:

答案 0 :(得分:0)

尝试发布您的MasterPage和Page Layouts,这是最常见的原因。由于系统帐户是godmode,因此不会出现错误。

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

SharePoint Designer:
CheckIn =&gt;发布主要版本,点击确定按钮或转到网站上的/ _catalogs / masterpage。

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

答案 1 :(得分:0)

一些想法:

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

答案 2 :(得分:0)

请参阅我在帖子编辑中发布的代码。它解决了我的问题。

答案 3 :(得分:0)

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