Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

O365 CSOM - AuthorizationFilter is not working. #1139

@maratbakirov

Description

@maratbakirov

Hello,

Brief description

Please provide short description covering two areas:

  • expected behaviour
  • actual behavior

SharePoint API

Which version of SharePoint runtime do you use?

SPMeta2 API

Which version of SPMeta2 do you use? Use the following code snippet for your convenience. It shows all the details on SPMeta2 and SharePoint runtime used.

https://www.nuget.org/packages/SPMeta2.CSOM.Foundation-v16/1.2.140?_src=template

var info = SPMeta2Diagnostic.GetDiagnosticInfo();

SPMeta2 model

Optionally, provide SPMeta2 model in which issue occurs. That helps to identify the issue and provide the solution as far as we can.

/// your SPMeta2 definitions and model here

we have web parts that we add to the page. seems that webparts AuthorizationFilter property has been ignored and we have to develop a workaround like this - i did not see a similar code in the spmeta2 csom sources:

    public static void FixAudienceTargeting(Microsoft.SharePoint.Client.File file, 
        SPMeta2.Definitions.WebPartDefinition webPartDefinition)
    {
        var ctx = file.Context;
        var lwpm = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
        var webParts = lwpm.WebParts;
        ctx.Load(webParts);
        ctx.ExecuteQueryWithIncrementalRetry();
        foreach(var wp in webParts)
        {
            ctx.Load(wp.WebPart, x => x.Title);
        }
        ctx.ExecuteQueryWithIncrementalRetry();
        var theWebPart = webParts.ToArray().Where(x => x.WebPart.Title == webPartDefinition.Title).First();
        theWebPart.WebPart.Properties["AuthorizationFilter"] = webPartDefinition.AuthorizationFilter;
        
        theWebPart.SaveWebPartChanges();

        file.Update();
        ctx.ExecuteQueryWithIncrementalRetry();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions