1

I'm trying to use my backend CSOM app with context of Site Collection Administrator service account to programmatically set a property bag value to store some settings for my frontend extension app.

I've tried doing it in 2 ways:

web.SetPropertyBagValue("name", "value");
ctx.ExecuteQuery();

and

web.AllProperties["name"] = "value";
web.Update();
ctx.ExecuteQuery();

but in both cases I get the error:

{"Access denied. You do not have permission to perform this action or access this resource."}

Is there really no way a Site Collection Administrator could set a property bag in SharePoint Online? I'm asking this because I've had similar issue when trying to delete a site, in which case according to a few sources on the Internet this operation could also be done only by tenant administrator but I found a method:

ctx.DeleteSiteAsync()

which turned out to be successfully deleting a site without tenant permissions. So I hope maybe there is also a solution here.

1 Answer 1

1

This is likely due to NoScript. To disable this, you must poses the SharePoint Admin or Global Admin role. It can be disabled via Get-PnPTenantSite or Set-SPOSite -DenyAddAndCustomizePages 0.

For each site, this is controlled by a tenant administrator. A Site Collection Admin can do anything, including deleting the site, except those things covered by NoScript restrictions unless NoScript has been disabled for that particular site.

2
  • Yes, but due to security considerations of disabling DenyAddAndCustomizePages I'm looking if there's any other way, maybe an API that's not restricted by NoScript. Dec 30, 2020 at 21:24
  • 1
    You can temporarily disable it and then re-enable it, or find an alternative solution to using Property Bags. But no, there is no alternative API (otherwise what would be the point of DenyAdd...?).
    – Trevor Seward
    Dec 30, 2020 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.