SharePoint Review Center

Everything about SharePoint – Architecture, Design, Development, Configuration, Administration, Issues, and Fixes

Access Denied Error Message While Editing Properties of any Document in a MOSS Document Library

Posted by Anthony Odole on January 30, 2009

 

When we go to properties of any document in document library even with full permission, we get access denied message if we try to edit the document properties. However we can open and edit the document successfully.

 

This is one of those errors that you spend a lot of time troubleshooting without a clue of why this is happening. As an experienced MOSS developer, you probably assume this is a permission issue; With this assumption, you use farm administrator account to log into the site, still you get access denied error page. You tried so many other steps, all to no avail. There is a good news and a bad news. Which one will you like me to talk about first? Just kidding!

 

Ok. The Good news is that you did not create or cause this issue. The bad news is that it is a bug. I’ve called and discussed this with the folks at Microsoft. There are two ways to fix this. Use step 1 to fix this issue in existing document libraries. Use step 2 to fix it in existing list templates

 

 

Step 1. For existing lists, you can run the following code to fix it. This here is a sample peace of code that should add the appropriate attribute to the list having the issue:

 

void FixField()

{

string RenderXMLPattenAttribute = “RenderXMLUsingPattern”

string weburl = “<http://localhost>”

string listName = “test2”

SPSite site = new SPSite(weburl);

SPWeb web = site.OpenWeb();

SPList list = web.Lists[listName];

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;

}

 

Step 2: For existing stp (list templates) that are having this problem, you should be able to modify the manifest.xml to add the attribute, and repackage the stp. You simply would rename the .stp file to a .cab file, open the manifest.xml file packaged in the cab, make this change that is highlighted:

 

<Field ID=”{BA3C27EE-4791-4867-8821-FF99000BAC98}”

Name=”PermMask”

SourceID=”http://schemas.microsoft.com/sharepoint/v3

StaticName=”PermMask”

RenderXMLUsingPattern=”TRUE”

Group=”_Hidden”

ReadOnly=”TRUE”

Hidden=”TRUE”

ShowInFileDlg=”FALSE”

Type=”Computed”

DisplayName=”$Resources:core,Effective_Perm_Mask;”>

<FieldRefs>

<FieldRef ID=”{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}” Name=”ID”/>

</FieldRefs>

<DisplayPattern>

<CurrentRights/>

</DisplayPattern>

</Field>

 

Then repackage the manifest.xml file to a .cab file and rename it back to .stp. Upload the list template to the template gallery. Any subsequent lists created with this template should work as expected.

Microsoft promised to fix this in the next hotfix. Please note that to prevent new list templates from having this problem, you will need to update the fieldswss.xml via the next Hotfix. Please do not update fieldswss.xml manually.

 

 

** About the Author: Anthony Odole is a Senior Solution Architect with IBM Global Services. He is a SharePoint Subject Matter Expert. You can reach him at Odolea@gmail.com

24 Responses to “Access Denied Error Message While Editing Properties of any Document in a MOSS Document Library”

  1. Anthony said

    Wahooooo it fixed my problem I’ve been fighting a whole day with this…. I guess the MOSS upgrades broke things… don’t know which one but thank you soooo much for posting!

    Here is my finished and tested code!

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

    namespace MossEditPropsFixer
    {
    class Program
    {
    static void Main(string[] args)
    {
    if (args.Length == 2)
    {
    string url = args[0];
    string listname = args[1];
    FixField(url, listname);
    Console.WriteLine(“Press any key to exit”);
    Console.ReadLine();
    }
    else
    {
    Console.WriteLine(“provide url and listname parameters”);
    Console.WriteLine(“Press any key to exit”);
    Console.ReadLine();

    }
    }

    private static void FixField(string weburl, string listName)
    {

    string RenderXMLPattenAttribute = “RenderXMLUsingPattern”;

    using (SPSite site = new SPSite(weburl))
    {

    using (SPWeb web = site.OpenWeb())
    {

    SPList list = web.Lists[listName];

    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;

    f.Update();
    list.Update();

    }
    }
    }

    }

    }

  2. Anthony Odole said

    Glad to know this fixed your issue

  3. John Creevy said

    Anthony,

    Through extensive testing in recreating VMs, we have seen this issue occur after the August Cumulative updates and not occur before. The access denied can be replicated by performing an export\import on any site or site collection on a farm that is at or greater than the August cumulative version. The February Cumulative updates does not repair the issue.

    We found the following added to the tp_Field in the dbo.AllLists SQL table for newly created Announcements and Surveys after an export\import is done on a post August update farm:

    Although we have seen this in Announcements and Survey Branching, we have not tested every list type. There may be other instances where the access denied occurs.

    As your repair is for existing lists with the problem, would you have any insight into what one can do now to prevent any new lists from inheriting the problem?

    Did Microsoft share root cause?

    Did Microsoft indicate the ETA on the hotfix?

  4. John Creevy said

    We’ll try posting the code again:

  5. Thank a lot Anthony, you enlightened my day… 🙂

  6. John Creevy said

    Anthony,

    Here is the repost:

    Through extensive testing in recreating VMs, we have seen this issue occur after the August Cumulative updates and not occur before. The access denied can be replicated by performing an export\import on any site or site collection on a farm that is at or greater than the August cumulative version. The February Cumulative updates does not repair the issue.

    We found the following added to the tp_Field in the dbo.AllLists SQL table for newly created Announcements and Surveys after an export\import is done on a post August update farm:

    Although we have seen this in Announcements and Survey Branching, we have not tested every list type. There may be other instances where the access denied occurs.

    As your repair is for existing lists with the problem, would you have any insight into what one can do now to prevent any new lists from inheriting the problem?

    Did Microsoft share root cause?

    Did Microsoft indicate the ETA on the hotfix?

  7. John Creevy said

    Field ID=”{ba3c27ee-4791-4867-8821-ff99000bac98}” Name=”PermMask” SourceID=”http://schemas.microsoft.com/sharepoint/v3″ StaticName=”PermMask” Group=”_Hidden” ShowInFileDlg=”FALSE” Type=”Computed” DisplayName=”Effective Permissions Mask” Hidden=”TRUE” ReadOnly=”TRUE” Version=”1

  8. hadaak said

    Here is MS fix:
    The PermMask field definition is out of sync between the base type definition and
    the shared column definition — specifically missing the
    RenderXMLUsingPattern
    definition in the latter case.

    Description of the Windows SharePoint Services 3.0 cumulative update package: February 24, 2009

    http://support.microsoft.com/kb/961755

    Description of the SharePoint Server 2007 cumulative update package (MOSS server-package): February 24, 2009
    http://support.microsoft.com/kb/961756

  9. Robin Martin said

    Anyone know if this has been fixed by a Microsoft release/patch/hotfix?

    Thanks,
    Robin

  10. Dave Cornall said

    You can use the following code to recurse through sites in a site collection and lists within each site if you find a large number of lists are broken. Code was hacked together from the above example and could be refactored but works!


    static void FixWebField()
    {

    string RenderXMLPattenAttribute = "RenderXMLUsingPattern";
    string weburl = "http://devproject/ProjectTest/";

    SPSite site = new SPSite(weburl);
    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";
    //string weburl = "http://devproject/ProjectTest/96036 IBM CSMS 2009";
    //string listName = "How Do I";
    SPSite site = new SPSite(weburl);
    SPWeb web = site.OpenWeb();
    web.AllowUnsafeUpdates = true;
    web.Update();

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

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

    }

  11. Dave Cornall said

    static void FixWebField()
            {
    
                string RenderXMLPattenAttribute = "RenderXMLUsingPattern";
                string weburl = "http://devproject/ProjectTest/";
    
                SPSite site = new SPSite(weburl);
                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";
                        //string weburl = "http://devproject/ProjectTest/96036 IBM CSMS 2009";
                        //string listName = "How Do I";
                        SPSite site = new SPSite(weburl);
                        SPWeb web = site.OpenWeb();
                        web.AllowUnsafeUpdates = true;
                        web.Update();
    
                        System.Collections.Generic.IList guidArrayList = new System.Collections.Generic.List(); 
    
                        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;
                        }
                        
                        
                }
    
  12. I really enjoyed reading your post, keep on making such interesting posts!

  13. rany said

    you should run this code with moss admin account

  14. i tried the first step and it works and solve the problem of Access Denied Error Message While Editing Properties of any Document in a MOSS Document Library

  15. Sampada said

    I am getting the same error but i don’t have access to the server.
    Can we solve this with client side code?
    Thanks in advance for the help.

    • Anthony Odole said

      You need a console application to run the code; talk to your server administrator because this issue occur after service pack was applied to the server.

  16. Shubhangi said

    Even I got this type of problem in WSS 3.0. I tried the first approach and it worked!! Thanks . Also I would like to know has MS came up with any hotfix/cumulative updates to resolve this known bug?

    Thanks All.

  17. Michael Caldecott said

    Dear All,

    I am totally new to all this C# stuff, however today we noticed our SharePoint WSS 3.0 experienced the same issue within a number of our sub-sites. If we try and use the edit command it just pops up with access denied.

    I can see the code above fixes this known bug, however I do not know how to use C# or Visual Studio. Please could someone email over a complied output file to my mailbox so I can fix this issue on our SP Server tomorrow?

    Please kindly help….

    Kind regards,
    Michael Caldecott (England)

    ————-

    Dear Anthony,

    Scratch the last message, I was going to test this on a sub-site called “test” and it failed; however I took a chance on the root directory and I saw magic happen!!! Its totally fixed…. Thank you so much, you are a star and very professional helping out a stranger thousands of miles away.

    I would like to say a warm thank you for taking a moment out of your day to help me, do you shop online at Amazon?

    Kind regards,
    Michael Caldecott

  18. Lydia said

    This script worked for me as well. My problem occurred when 2.0 sites were migrated into an existing 3.o site collection. I particularly appreciate the explanation on using the code. That saved me a lot of time.
    Thanks

  19. Piotr said

    Great post !!!

    Thanks

  20. I’ve been reading a few posts and really and enjoy your writing. I’m just setting up my own blog and only hope that I can write as well and give the reader so much insight.

  21. […] console application (you can use the one that has been created by Anthony Odole or the one created by […]

Leave a reply to Michael Caldecott Cancel reply