Sharepoint:编辑页面(由于页面布局)或列表项时拒绝访问
我是以系统帐户登录的,所以可能不是“真正的访问被拒绝”! 我所做的: -自定义母版页 -来自自定义内容类型(带有自定义字段)的自定义页面布局 如果我在页面布局中添加自定义字段(在SPD中的工具中称为“内容字段”),则当我尝试编辑来自该页面布局的页面时,访问被拒绝 例如,如果我在页面布局中添加“asp:content”标记中的这一行: 我被拒绝访问。如果我把它拿走,一切都好。(字段“test”是来自内容类型的字段) 有什么想法吗 更新 嗯,我在一个空白的网站上试过,效果很好,所以我的web应用程序肯定有问题:( 更新#2 母版页中的这一行似乎给了我拒绝访问的权限:Sharepoint:编辑页面(由于页面布局)或列表项时拒绝访问,sharepoint,master-pages,access-denied,page-layout,Sharepoint,Master Pages,Access Denied,Page Layout,我是以系统帐户登录的,所以可能不是“真正的访问被拒绝”! 我所做的: -自定义母版页 -来自自定义内容类型(带有自定义字段)的自定义页面布局 如果我在页面布局中添加自定义字段(在SPD中的工具中称为“内容字段”),则当我尝试编辑来自该页面布局的页面时,访问被拒绝 例如,如果我在页面布局中添加“asp:content”标记中的这一行: 我被拒绝访问。如果我把它拿走,一切都好。(字段“test”是来自内容类型的字段) 有什么想法吗 更新 嗯,我在一个空白的网站上试过,效果很好,所以我的web应用程序
<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Visible="false"
PrefixHtml="<tr><td colspan="0" id="mpdmconsole" class="s2i-consolemptablerow">"
SuffixHtml="</td></tr>"></SharePoint:DelegateControl>
更新#3
我发现
看起来是类似的问题。但是我们的Sharepoint版本具有最新更新。我将尝试使用修复列表的代码并发布另一个更新
**更新#4**
好的……我尝试了我在上面页面上找到的代码(见链接),它似乎解决了问题。我还没有100%测试解决方案,但到目前为止,效果很好。以下是我为功能接收器编写的代码(我使用了上面链接发布的代码):
使用系统;
使用System.Collections.Generic;
使用系统文本;
使用Microsoft.SharePoint;
使用System.Xml;
命名空间MyWebsite.FixAccessDenied
{
类FixAccessDenied:SPFeatureReceiver
{
公共覆盖无效功能已激活(SPFeatureReceiverProperties)
{
FixWebField(SPContext.Current.Web);
}
公共覆盖无效功能停用(SPFeatureReceiverProperties)
{
//抛出新异常(“方法或操作未实现”);
}
已安装公共覆盖无效功能(SPFeatureReceiverProperties)
{
//抛出新异常(“方法或操作未实现”);
}
公共覆盖无效功能卸载(SPFeatureReceiverProperties)
{
//抛出新异常(“方法或操作未实现”);
}
静态无效FixWebField(SPWeb currentWeb)
{
字符串renderxmlpattribute=“RenderXMLUsingPattern”;
SPSite站点=新的SPSite(currentWeb.Url);
SPWeb=site.OpenWeb();
web.AllowUnsafeUpdates=true;
web.Update();
SPField f=web.Fields.GetFieldByInternalName(“PermMask”);
字符串s=f.SchemaXml;
Console.WriteLine(“schemaXml在:+s之前”);
XmlDocument xd=新的XmlDocument();
xd.LoadXml;
XmlElement xe=xd.DocumentElement;
if(xe.Attributes[renderxmlpattribute]==null)
{
XmlAttribute attr=xd.CreateAttribute(renderXmlPatternatAttribute);
attr.Value=“TRUE”;
Attributes.Append(attr);
}
字符串strXml=xe.OuterXml;
WriteLine(“schemaXml在“+strXml”之后);
f、 SchemaXml=strXml;
foreach(site.AllWebs中的SPWeb站点)
{
FixField(sites.Url);
}
}
静态void FixField(字符串weburl)
{
字符串renderxmlpattribute=“RenderXMLUsingPattern”;
SPSite站点=新的SPSite(weburl);
SPWeb=site.OpenWeb();
web.AllowUnsafeUpdates=true;
web.Update();
System.Collections.Generic.IList guidArrayList=新的System.Collections.Generic.List();
foreach(web.Lists中的SPList列表)
{
guidArrayList.Add(list.ID);
}
foreach(guidArrayList中的Guid)
{
SPList list=web.Lists[guid];
SPField f=list.Fields.GetFieldByInternalName(“PermMask”);
字符串s=f.SchemaXml;
Console.WriteLine(“schemaXml在:+s之前”);
XmlDocument xd=新的XmlDocument();
xd.LoadXml;
XmlElement xe=xd.DocumentElement;
if(xe.Attributes[renderxmlpattribute]==null)
{
XmlAttribute attr=xd.CreateAttribute(renderXmlPatternatAttribute);
attr.Value=“TRUE”;
Attributes.Append(attr);
}
字符串strXml=xe.OuterXml;
WriteLine(“schemaXml在“+strXml”之后);
f、 SchemaXml=strXml;
}
}
}
}
只需将该代码作为功能接收器,并在根站点上激活它,它就会在所有子站点中循环并修复列表
摘要
编辑页面或项目时,您会被拒绝访问
即使你以f****世界超级管理员的身份登录,你仍然会收到错误(对不起,我花了3天时间处理这个错误)
对我来说,它发生在从另一个站点定义(cmp文件)导入之后
事实上,它应该是一个已知的bug,并且应该从2009年2月开始修复,但看起来不是
我上面发布的代码应该可以解决这个问题。尝试发布母版页和页面布局,这是最常见的原因。因为系统帐户是godmode,所以不会出现此错误 在SharePoint Designer中,您无法执行发布工作流的最后一步(批准),因此您: SharePoint设计器:
签入=>发布主要版本,点击OK按钮或转到站点上的/_目录/母版页 然后,使用关联菜单批准
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;
}
}
}
}