This repository was archived by the owner on Mar 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
O365 CSOM - AuthorizationFilter is not working. #1139
Copy link
Copy link
Open
Description
Hello,
Brief description
Please provide short description covering two areas:
- expected behaviour
- actual behavior
SharePoint API
Which version of SharePoint runtime do you use?
- CSOM / SSOM / O365?
https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/16.1.9021.1200?_src=template
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 herewe 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
Labels
No labels