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

发布于 2024-08-17 16:13:17 字数 5137 浏览 11 评论 0原文

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

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

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

有什么想法吗?

更新

嗯,我在一个空白网站中尝试过,它工作正常,所以我的网络应用程序一定有问题:(

更新 #2

看起来像 master 中的这一行页面给我拒绝访问:

<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**

好的...我尝试了在上面页面上找到的代码(请参阅链接),它似乎修复了我没有的问题。 t 测试了 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;
            }

        }

    }
}

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

摘要

在编辑页面项目时收到访问被拒绝

消息,即使您“以该死的世界的超级管理员身份重新登录(抱歉,我花了 3 天来解决这个错误)

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

实际上,它应该是一个已知的错误,本应自 2009 年 2 月起修复,但看起来并没有修复。

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

I'm logged in as the System Account, so it's probably not a "real access denied"!
What I've done :
- A custom master page
- A custom page layout from a custom content type (with custom fields)

If I add a custom field (aka "content field" in the tools in SPD) in my page layout, I get an access denied when I try to edit a page that comes from that page layout.

So, for example, if I add in my page layout this line in a "asp:content" tag :

I get an access denied. If I remove it, everyting is fine. (the field "test" is a field that comes from the content type).

Any idea?

UPDATE

Well, I tried in a blank site and it worked fine, so there must be something wrong with my web application :(

UPDATE #2

Looks like this line in the master page gives me the access denied :

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

UPDATE #3

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

Looks like a similar issue. But our Sharepoint versions are with the latest updates. I'll try to use the code that's supposed to fix the lists and post another update.

** UPDATE #4**

OK... I tried the code that I found on the page above (see link) and it seems to fix the thing. I haven't tested the solution at 100% but so far, so good. Here's the code I made for a feature receiver (I used the code posted from the link above) :

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;
            }

        }

    }
}

Just put that code as a Feature Receiver, and activate it at the root site, it should loop trough all the subsites and fix the lists.

SUMMARY

You get an ACCESS DENIED when editing a PAGE or an ITEM

You still get the error even if you're logged in as the Super Admin of the f****in world (sorry, I spent 3 days on that bug)

For me, it happened after an import from another site definition (a cmp file)

Actually, it's supposed to be a known bug and it's supposed to be fixed since February 2009, but it looks like it's not.

The code I posted above should fix the thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

哽咽笑 2024-08-24 16:13:17

尝试发布您的母版页和页面布局,这是最常见的原因。由于系统帐户是 Godmode,因此不会出现该错误。

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

SharePoint Designer:
签到 =>发布主要版本,点击“确定”按钮或转到网站上的 /_catalogs/masterpage 。

然后使用上下文菜单批准母版页和布局。

Try to publish your MasterPage and Page Layouts, this is the most common reason. Since the system account is godmode, it wont get that error.

In SharePoint Designer you cannot do the last step in the publishing workflow (Approval), so you:

SharePoint Designer:
CheckIn => Publish Major Version, hit the OK button or go to /_catalogs/masterpage on the site .

Then and use the Context Menu to Approve the MasterPage and Layouts.

咽泪装欢 2024-08-24 16:13:17

一些想法:

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

Some ideas:

  • Check if any web parts in your custom Page Layout and Master Page are not registered as safe.
  • Did you define your own custom field type, like write a class which extends SPField? If so, are you using a custom Field Control? If you are, check if it is doing anything which may need elevated privileges.
  • Likewise, check for any edit mode panels containing web parts of web controls which might be trying to do something which needs elevated privileges.
夜访吸血鬼 2024-08-24 16:13:17

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

See the code I've posted in the edit of the post. It fixed my problem.

独﹏钓一江月 2024-08-24 16:13:17

该问题似乎是由某些版本的 SharePoint 中的 stsadm -o export 函数中的错误引起的(我从 2007 RTM MOSS 服务器进行导出)。导入伪造的导出文件会导致所有新创建的列表中出现“编辑拒绝访问”问题。微软后续版本的补丁修复了stsadm -o导出,但不修复损坏的列表;这需要像tinky05这样的过程。

The problem appears to be caused by an error in the stsadm -o export function in certain versions of SharePoint (I got it doing an export from a 2007 RTM MOSS server). Importing the bogus export file causes the "edit-denied-access" problem in all NEWLY-CREATED lists. The patches for later version from Microsoft fix stsadm -o export, but DO NOT FIX the broken lists; that requires a procedure like tinky05's.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文