Associated errors:

“Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. You don’t have Add and Customize Pages permissions required to perform this action.”

Access Denied to certain web pages that you should be able to see

Missing sections / headings in Site Settings such as Solutions Gallery – you should see in site settings

 

blog image

Problem:

I was working on one of our client’s sites on a brand new Office 365 configuration and after a while found that on my admin account I was being denied access to certain things and being told I didn’t have permission to do certain things. This was strange as I was logged on with the admin account and there were no other accounts yet created.

Diagnostics:

To check if this is your issue go to a library where the issue is occurring and check permissions for your account. Go to the Library tab and select Shared With on the ribbon then go straight to “advanced”. Select Check permissions on the ribbon at the top – enter your user account and do check now.

If you see this:

 

blog image

Or if any of your Galleries are missing as shown above from Site Settings then...

Resolutions:

Firstly to stop it happening again...

To enable or disable scripting from the SharePoint admin centre

Sign in to Office 365 with your work or school account.

Go to the SharePoint admin centre.

Select Settings.

Under Custom Script choose:

 

blog image

Any change to the scripting setting made through the SharePoint Online admin centre may take up to 24 hours to take effect.

To fix the current problem

To enable scripting on a particular site collection immediately, use the following PowerShell command.

In SharePoint online management shell (download if you don’t have it)

Enter:

Connect-SPOService

then

Enter URL of admin site https://-admin.sharepoint.com

Then username and password

Set-SPOSite -Identity https://.sharepoint.com -DenyAddAndCustomizePages $false

Make sure the scripting setting in the admin portal matches what you set using PowerShell, or the site collection setting may be overridden again in the next 24 hours.

When you then run the command all should be well again and it should not happen again!