File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
src/Resources/Resources/Models.Authorization Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,13 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
234
234
* objectId could represent a group, so can't use atScope() and assignedTo('{objectId}') as alternative,
235
235
* must filter after the results return from server.
236
236
*/
237
+
238
+ // Only GUIDs are currently supported as ObjectId. If the value is not a GUID, the call and result filtering can be skipped.
239
+ if ( ! Guid . TryParse ( principalId , out Guid _ ) )
240
+ {
241
+ return new List < PSRoleAssignment > ( ) ;
242
+ }
243
+
237
244
odataQuery = new ODataQuery < RoleAssignmentFilter > ( f => f . AtScope ( ) ) ;
238
245
needsFilterPrincipalId = true ;
239
246
}
@@ -264,11 +271,17 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
264
271
result = result . Where ( r => r . RoleDefinitionName ? . Equals ( options . RoleDefinitionName , StringComparison . OrdinalIgnoreCase ) ?? false ) . ToList ( ) ;
265
272
}
266
273
267
- if ( needsFilterPrincipalId && Guid . TryParse ( principalId , out Guid principalAsGuid ) )
274
+ if ( needsFilterPrincipalId )
268
275
{
269
- result = result
270
- . Where ( r => Guid . TryParse ( r . ObjectId , out Guid objectIdAsGuid ) && objectIdAsGuid == principalAsGuid )
271
- . ToList ( ) ;
276
+ if ( Guid . TryParse ( principalId , out Guid principalAsGuid ) ) {
277
+ result = result
278
+ . Where ( r => Guid . TryParse ( r . ObjectId , out Guid objectIdAsGuid ) && objectIdAsGuid == principalAsGuid )
279
+ . ToList ( ) ;
280
+ }
281
+ else
282
+ {
283
+ result = new List < PSRoleAssignment > ( ) ;
284
+ }
272
285
}
273
286
274
287
if ( options . IncludeClassicAdministrators )
You can’t perform that action at this time.
0 commit comments