Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when setting "DenyAddAndCustomizePages" on the site properties. #1592

Open
1 task done
acmurchison-il opened this issue Dec 18, 2024 · 7 comments
Open
1 task done

Comments

@acmurchison-il
Copy link

Category

  • Bug

Describe the bug

When setting the "DenyAddAndCustomizePages" on site properties, it's throwing a PnP.Core.CsomServiceException with the message "The requested operation is part of an experimental feature that is not supported in the current environment.". The value is actually set in SharePoint but we shouldn't be getting an exception returned. Potentially is a Microsoft update that is making this occur.

Both settings cause an issue:
image

Steps to reproduce

When calling the 'Update' method it throws the exception PnP.Core.CsomServiceException
image

Expected behavior

No Exception is thrown when it successfully sets in SharePoint.

Environment details (development & target environment)

  • SDK version: [Pnp.Core 1.14.0]
  • OS: Windows 11
  • SDK used in: Reproduced in Test Framework (.NET 8.0, Console Application). Also seeing in an Azure Function.
  • Framework: .NET8.0
  • Browser(s): null
  • Tooling: VS2022
  • Additional details:

Additional context

Thanks for your contribution! Sharing is caring.

@fzbm
Copy link
Contributor

fzbm commented Dec 20, 2024

We had the same issue and switched back to CSOM for this, because there it is still working. Our production environment was affected and we needed a solution for this issue fast. What we also determined is, that even if the error occurred, the state has still been changed. Nevertheless this issue should be looked into and getting fixed.

While PnP Core uses hand crafted CSOM requests for this, it looks like there is still a difference between the requests of the original library and PnP, which then triggers a different path on the server.

@ajcaterino
Copy link

ajcaterino commented Dec 20, 2024

We are also seeing the same issues when setting Site Collection properties. We set the StorageMaximumLevel and the value is not saved.

@LutzD-pkb
Copy link

Seems like it's just setting any site collection properties. I've tried StorageMaximumLevel, StorageWarningLevel, SharingCapability, DefaultSharingLinkType, and DefaultLinkToExistingAccess.. all produce this error.

@raclettierer
Copy link

we have the same problem. @fzbm can you share your workaround ?

@LutzD-pkb
Copy link

@raclettierer we worked around the issue using PnP Framework using the interop. The Site Collection Properties property is similar, there's just some extra scaffolding needed to initiate an admin center context, load the properties, and then save them:

//get the admin context from existing site context   
var adminCenterContext = await pnpContext.GetSharePointAdmin().GetTenantAdminCenterContextAsync();

//create a PnP Framework CSOM context from the PnP Core context
using ClientContext csomContext = PnPCoreSdk.Instance.GetClientContext(adminCenterContext);

//get the site properties
var tenant = new Microsoft.Online.SharePoint.TenantAdministration.Tenant(csomContext);
var siteAdminProperties = tenant.GetSitePropertiesByUrl(siteUrl, true);
tenant.Context.Load(siteAdminProperties);
await tenant.Context.ExecuteQueryRetryAsync();

//update site properties
siteAdminProperties.SharingCapability = Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities.Disabled;
siteAdminProperties.Update();

//execute the query (the "Update" method doesn't actually save the change in PnP Framework)
await tenant.Context.ExecuteQueryRetryAsync();

This obviously introduces some tech debt because the PnP Framework is pseudo-deprecated, but it works.

@Gregorly
Copy link

Gregorly commented Jan 7, 2025

We also have this issue, it was working in production the entirety of 2024 until around this issue was created. seriously frustrated. I am reluctant to use the work around because if this issue is fixed, a revert will need to be done.

Thanks for sharing your code @LutzD-pkb

@fzbm
Copy link
Contributor

fzbm commented Jan 8, 2025

we have the same problem. @fzbm can you share your workaround ?

Sorry, was not able to answer yesterday, but @LutzD-pkb already posted an example of how we did this.

Instead of using the PnP Core method to get a ClientContext from a PnPContext we already had another way to get one. So if you already have an alternative way to get ClientContext instances, you can remove the dependency to PnP Framework. Also replace ExecuteQueryRetryAsync with ExecuteQueryAsync in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants