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

Retrieving Role Assignment details throws exception with Sharing Links #1386

Open
1 task done
JarodAI opened this issue Feb 7, 2024 · 0 comments
Open
1 task done
Assignees
Labels
question Further information is requested

Comments

@JarodAI
Copy link

JarodAI commented Feb 7, 2024

Category

  • Bug

Describe the bug

When I try to retrieve the role assignments of a file an exception is thrown if there is a Sharing link.
The error is the following:

HttpResponseCode: 404
Code: System.ArgumentException
Message: Can not find the principal with id: 27.
ClientRequestId: af5209a1-407b-8000-0bec-4440f98dde8d
SPClientServiceRequestDuration: 23
X-SharePointHealthScore: 0
X-SP-SERVERSTATE: ReadOnly=0

the id 27 in the example matches the assigned id of the sharing link

image

Steps to reproduce

See code:
I want to extract permissions that includes a specific permission kind

var listItem = file.ListItemAllFields;
await listItem.LoadAsync(
    w => w.HasUniqueRoleAssignments,
    w => w.RoleAssignments.QueryProperties(
         p => p.PrincipalId,
         p => p.RoleDefinitions.QueryProperties(
             rd => rd.Id,
             rd => rd.Name,
             rd => rd.BasePermissions)));
var ras = listItem.RoleAssignments;
PermissionKind permissionKind = PermissionKind.ViewListItems; 
//The following line throws the exception
List<IRoleAssignment> filteredRoles = ras.AsRequested().Where(
               ra => ra.RoleDefinitions.ToList().Any(
                   rd => rd.BasePermissions.Has(permissionKind))).ToList();

Expected behavior

No exception thrown and have access to the required roles assignments

Environment details (development & target environment)

  • SDK version: 1.11
  • OS: Windows 11
  • SDK used in: Console App
  • Framework: .NET Core v8
  • Tooling: Visual Studio 2022

Thanks for your contribution! Sharing is caring.

@jansenbe jansenbe self-assigned this Mar 13, 2024
@jansenbe jansenbe added the question Further information is requested label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants