Share via


You cannot edit list or document library items on existing SharePoint sites

This problem was fixed in KB961175. The patch will keep the problem from happening again in new lists/libraries you create after applying the patch. However if you have a backup before the patch the restored contents will continue to show the same error. It is also true to existing items. In order to fix this other issue, Microsoft released KB971351 showing some code to fix the problem in existing items. There are two code blocks: one for webs and another for lists. At the time of this writing the codes contained some minor typos and also some memory leaks. Nothing that would prevent a developer to make it work. The memory leak is not an issue as well since it is supposed to only run once. I understand that most of the support people are not that into coding, I put together a more intuitive code together which can be downloaded here (including executable):

https://rodneyviana.codeplex.com/

 

How do you know you are experience this problem?

The symptom is having someone with full access to a site collection, web, list or document library being unable to edit list items (user receives access denied) however user can see list items using view item.

 

Source Code:

You know the disclaimer: I work for Microsoft but the code I put in codeplex is NOT endorsed by Microsoft. This is a community tool and must be treated as such. That being told, the application complies with Microsoft best practices and can be used in your environment if you are experiencing the problems described in KB961175. The application will not change anything if you are not facing the problem described.

 

This is the full source code:

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

namespace KB971351
{
class Program
{
static private string RenderXMLPattenAttribute = "RenderXMLUsingPattern";
static private string webUrl = "https://localhost";

        static void FixList()
{
Console.Write("Please enter web site (https://localhost): ");
string inputWeb = Console.ReadLine();
if (!String.IsNullOrEmpty(inputWeb))
webUrl = inputWeb;
Console.WriteLine("\nTrying to open web site: {0}", webUrl);
string listName = null;
try
{
using (SPSite site = new SPSite(webUrl))
{
Console.WriteLine("Web site {0} found", webUrl);
using (SPWeb web = site.OpenWeb())
{
while (String.IsNullOrEmpty(listName))
{
Console.Write("Enter list name or press [enter] to display all lists: ");
listName = Console.ReadLine();
if (String.IsNullOrEmpty(listName))
{
for (int i = 0; i < web.Lists.Count; i++)
{
if (!web.Lists[i].Hidden)
Console.WriteLine(web.Lists[i].Title);
}
}

                        }

                        SPList list = web.Lists[listName];
SPField f = list.Fields.GetFieldByInternalName("PermMask");
string s = f.SchemaXml;
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;
f.SchemaXml = strXml;
Console.WriteLine("SUCESS: problem identified in KB 971351 was found and fixed");
}
else
{
Console.WriteLine("WARNING: problem identified in KB 971351 was NOT found. No change was made");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("\nApplication Failed with error: {0}", ex.Message);
Console.WriteLine("No changes were made. Please run application again");

            }

        }

        static void FixWeb()
{
Console.Write("Please enter web site (https://localhost): ");
string inputWeb = Console.ReadLine();
if (!String.IsNullOrEmpty(inputWeb))
webUrl = inputWeb;
Console.WriteLine("\nTrying to open web site: {0}", webUrl);
try
{
using (SPSite site = new SPSite(webUrl))
{
Console.WriteLine("Web site {0} found", webUrl);
using (SPWeb web = site.OpenWeb())
{
SPField f = web.Fields.GetFieldByInternalName("PermMask");
string s = f.SchemaXml;
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;
f.SchemaXml = strXml;
Console.WriteLine("SUCESS: problem identified in KB 971351 was found and fixed");
}
else
{
Console.WriteLine("WARNING: problem identified in KB 971351 was NOT found. No change was made");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("\nApplication Failed with error: {0}", ex.Message);
Console.WriteLine("No changes were made. Please run application again");

            }

        }

        static void Main(string[] args)
{
Console.WriteLine("Implementation of code in KB 971351");
Console.WriteLine("====================================");
Console.WriteLine("Written by Rodney Viana");
Console.WriteLine("More info at https://blogs.msdn.com/rodneyviana and https://support.microsoft.com/kb/971351 \n");
Console.WriteLine("This sample application is supplied \"AS IS\"");
Console.WriteLine("It is ONLY for demonstration/proof of concept purposes");
Console.WriteLine("If you DO NOT agree with the license at:\n\thttps://www.codeplex.com/rodneyviana/license\n\tPress Ctrl+C\n\n\n");
Console.WriteLine("Choose one of the options below:");
Console.WriteLine("0. If you don't want to do it now and end the application");
Console.WriteLine("1. If you are experiencing problems in anye web site fields");
Console.WriteLine("2. If you are experiencing problems in a list or document library");
ConsoleKeyInfo key = new ConsoleKeyInfo();
while(key == null || (key.KeyChar != '0' && key.KeyChar != '1' && key.KeyChar != '2'))
{
key = Console.ReadKey();
}

            if(key.KeyChar == '1')
{
Console.WriteLine("You have chosen to fix a web site");
FixWeb();
}

            if(key.KeyChar == '2')
{
Console.WriteLine("You have chosen to fix a list");
FixList();
}

            if(key.KeyChar == '0')
{
Console.WriteLine("You have chosen to abort application");
}
Console.Write("Press any key...");
Console.ReadKey();

        }
}
}

Comments

  • Anonymous
    January 07, 2010
    Thank you very much for this exe. I have run it successfully on our test SharePoint environment and plan on testing in our production SharePoint environemnt soon.

  • Anonymous
    January 12, 2010
    The comment has been removed

  • Anonymous
    January 18, 2010
    The comment has been removed

  • Anonymous
    April 13, 2010
    Thanks for the executable. we have run this executable on Tes Environment and is successful with no issues. Great work!

  • Anonymous
    September 18, 2010
    For some reason I couldn't seem to get the code publised in the KB article to work when I put it into VS2010 on my x64 Server 2008 R2 environment. I know I was doing something wrong but I am new to programming c# so it was driving me insane. Running your modified pre-built application worked a treat - thank you sooooo much for this you are an absolute legend!! Thank you for spending the time to publish this and awesome work! Rich

  • Anonymous
    December 10, 2010
    Just wanted to say thanks, this worked like a charm.  We got a site template from another group in our company and they are on a version of MOSS before this was fixed, so using it is what caused the issue for us.

  • Anonymous
    November 01, 2013
    It is good to be true, don't immitate us ....

  • Anonymous
    July 23, 2015
    Great work, plan shared worded nicely!!!