pnp / pnp/pnpframework

ACSauthManager.GetACSAppOnlyContext is unable to set external access policy since 08/04

Open
#439 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

We have been using PnP.Framework to set some properties for the sites once the site is provisioned and it was working fine until 08/04 but suddenly the process started failing when setting sharingcapabilities to disabled. Other things work fine with the same ACS context and it happens on 2 different tenants.

In the below code enabling custom scripts part of the code works fine but "siteProperties.SharingCapability = SharingCapabilities.Disabled;" part fails. We are getting a 401 Unauthorized when it tries to set this property.

using (var context = ACSauthManager.GetACSAppOnlyContext(GetAdminSiteUrl(item.siteUrl, log), ClientID, ClientSecret))
{
                    var tenant = new Tenant(context);
                    var siteProperties = tenant.GetSitePropertiesByUrl(item.siteUrl, true);
                    log.LogInformation("Enabling Custom Scripts");
                    tenant.SetSiteProperties(item.siteUrl, noScriptSite: false);
                    context.ExecuteQuery();
                    log.LogInformation("Setting external access policies");
                    if (!item.isExternal)
                    {
                        log.LogInformation("Request is not an external site, setting sharing capabilities to disabled");
                        siteProperties.SharingCapability = SharingCapabilities.Disabled;
                        siteProperties.Update();
                        context.ExecuteQuery();
                        log.LogInformation("Completed setting external access policies");
                    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ACSauthManager.GetACSAppOnlyContext and trace the Tenant site-property operations shown in the issue. Compare the successful noScriptSite update with the SharingCapability update, reproduce the 401 Unauthorized response across the two reported tenant scenarios, and confirm that external access policy setting works without regressing custom-script updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.