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
234234 * objectId could represent a group, so can't use atScope() and assignedTo('{objectId}') as alternative,
235235 * must filter after the results return from server.
236236 */
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+
237244 odataQuery = new ODataQuery < RoleAssignmentFilter > ( f => f . AtScope ( ) ) ;
238245 needsFilterPrincipalId = true ;
239246 }
@@ -264,11 +271,17 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
264271 result = result . Where ( r => r . RoleDefinitionName ? . Equals ( options . RoleDefinitionName , StringComparison . OrdinalIgnoreCase ) ?? false ) . ToList ( ) ;
265272 }
266273
267- if ( needsFilterPrincipalId && Guid . TryParse ( principalId , out Guid principalAsGuid ) )
274+ if ( needsFilterPrincipalId )
268275 {
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+ }
272285 }
273286
274287 if ( options . IncludeClassicAdministrators )
You can’t perform that action at this time.
0 commit comments