Sitecore Error: AddFromTemplate - Add Access Required

I am trying to add an image element to the content tree, but I get an access denied error in the following paragraph:

item.Add ("New Node1" ...

Full code of my method:

Sitecore.Data.Database master;
master = Sitecore.Configuration.Factory.GetDatabase("master");
Item item = master.Items["/sitecore/Content/Media/Images/Places"];
//  item.Fields["Related Issues"].Value = "Asia and the Pacific";
if (item != null)
{
    // add a new Item based on  the Document Template
    Item itm = item.Add("New Node1", master.Templates[new ID(new Guid("EJ0F53DF-5486-4UF4-A2D1-64C119E419A5"))]);
    if (itm != null)
    {
        // report the Item path to the User
        Response.Write(itm.Paths.Path);
    }
}
+3
source share
1 answer

It is possible that the Sitecore user context is running and does not have rights to this part of the content tree. Check this out using the Access Viewer. If so, wrap the method in Security Disabler, for example:

using (new Sitecore.SecurityModel.SecurityDisabler())
{
  // enter your code here
}
+9
source

Source: https://habr.com/ru/post/1720222/


All Articles