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

O365 CSOM - AuthorizationFilter is not working. #1139

Open
maratbakirov opened this issue Jul 25, 2019 · 0 comments
Open

O365 CSOM - AuthorizationFilter is not working. #1139

maratbakirov opened this issue Jul 25, 2019 · 0 comments

Comments

@maratbakirov
Copy link
Contributor

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();
    }
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

1 participant