Skip to content

Commit

Permalink
GetUserEffectivePermissions not working with External accounts #1350
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Feb 15, 2024
1 parent 732526b commit 052a979
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Admin library: Add code to set sensitivity label to a group via updating associated site properties #1389 [wilecoyotegenius - Konrad K.]
- Expose the `BatchRequest.Id` property and include it in the corresponding `BatchResponse` to enable more advanced batch handling scenarios #1374 [jansenbe - Bert Jansen]
- Admin library: fixed issues with loading SharePoint Add-In and Azure ACS principal permissions when the payload exceeded 500 items [jansenbe - Bert Jansen]
- GetUserEffectivePermissions not working with External accounts #1350 [jansenbe - Bert Jansen]

## [1.11.0]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"82000ca1-001d-8000-23ec-98b49e054fd3","SPClientServiceRequestDuration":"9","X-SharePointHealthScore":"3","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022RegionalSettings\u0022:{\u0022TimeZone\u0022:{\u0022Description\u0022:\u0022(UTC-08:00) Pacific Time (US and Canada)\u0022,\u0022Id\u0022:13,\u0022Information\u0022:{\u0022Bias\u0022:480,\u0022DaylightBias\u0022:-60,\u0022StandardBias\u0022:0}},\u0022AdjustHijriDays\u0022:0,\u0022AlternateCalendarType\u0022:0,\u0022AM\u0022:\u0022AM\u0022,\u0022CalendarType\u0022:1,\u0022Collation\u0022:25,\u0022CollationLCID\u0022:2070,\u0022DateFormat\u0022:0,\u0022DateSeparator\u0022:\u0022/\u0022,\u0022DecimalSeparator\u0022:\u0022.\u0022,\u0022DigitGrouping\u0022:\u00223;0\u0022,\u0022FirstDayOfWeek\u0022:0,\u0022FirstWeekOfYear\u0022:0,\u0022IsEastAsia\u0022:false,\u0022IsRightToLeft\u0022:false,\u0022IsUIRightToLeft\u0022:false,\u0022ListSeparator\u0022:\u0022,\u0022,\u0022LocaleId\u0022:1033,\u0022NegativeSign\u0022:\u0022-\u0022,\u0022NegNumberMode\u0022:1,\u0022PM\u0022:\u0022PM\u0022,\u0022PositiveSign\u0022:\u0022\u0022,\u0022ShowWeeks\u0022:false,\u0022ThousandSeparator\u0022:\u0022,\u0022,\u0022Time24\u0022:false,\u0022TimeMarkerPosition\u0022:0,\u0022TimeSeparator\u0022:\u0022:\u0022,\u0022WorkDayEndHour\u0022:1020,\u0022WorkDays\u0022:62,\u0022WorkDayStartHour\u0022:480},\u0022Id\u0022:\u00222c99a486-d6c9-4a4b-8d6f-a9faa364c92c\u0022,\u0022Url\u0022:\u0022https://bertonline.sharepoint.com/sites/prov-2\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"82000ca1-a02b-8000-23ec-95f0eec3f8ef","SPClientServiceRequestDuration":"11","X-SharePointHealthScore":"2","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022GroupId\u0022:\u0022d40d729b-df60-4b57-ac8f-102595090e0a\u0022,\u0022Id\u0022:\u0022f92f9e40-1110-43ef-aa0e-0822e13fb7ba\u0022}"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"IsSuccessStatusCode":true,"StatusCode":200,"Headers":{"SPRequestGuid":"82000ca1-3092-8000-23ec-98493b15be62","SPClientServiceRequestDuration":"378","X-SharePointHealthScore":"0","X-SP-SERVERSTATE":"ReadOnly=0"},"Response":"{\u0022High\u0022:\u0022432\u0022,\u0022Low\u0022:\u00221011030767\u0022}"}
11 changes: 11 additions & 0 deletions src/sdk/PnP.Core.Test/SharePoint/WebTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,17 @@ public async Task GetEffectiveUserPermissionsAsyncTest()
}
}

[TestMethod]
public async Task GetEffectiveExternalUserPermissionsAsyncTest()
{
TestCommon.Instance.Mocking = false;
using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
{
var basePermissions = await context.Web.GetUserEffectivePermissionsAsync("bjansen_microsoft.com#ext#@bertonline.onmicrosoft.com");

Assert.IsNotNull(basePermissions);
}
}

[TestMethod]
public async Task CheckIfUserHasPermissionsAsyncTest()
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/PnP.Core/Model/SharePoint/Core/Internal/Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,7 @@ public async Task<IBasePermissions> GetUserEffectivePermissionsAsync(string user

private static ApiCall BuildGetUserEffectivePermissionsApiCall(string userPrincipalName)
{
return new ApiCall($"_api/web/getusereffectivepermissions('{HttpUtility.UrlEncode("i:0#.f|membership|")}{userPrincipalName}')", ApiType.SPORest);
return new ApiCall($"_api/web/getusereffectivepermissions('{HttpUtility.UrlEncode("i:0#.f|membership|" + userPrincipalName)}')", ApiType.SPORest);
}

public bool CheckIfUserHasPermissions(string userPrincipalName, PermissionKind permissionKind)
Expand Down

0 comments on commit 052a979

Please sign in to comment.