@@ -90,12 +90,7 @@ public PSRoleDefinition GetRoleDefinition(Guid roleId)
90
90
public List < PSRoleDefinition > FilterRoleDefinitions ( string name )
91
91
{
92
92
List < PSRoleDefinition > result = new List < PSRoleDefinition > ( ) ;
93
- ListDefinitionFilterParameters parameters = new ListDefinitionFilterParameters
94
- {
95
- RoleName = name
96
- } ;
97
-
98
- result . AddRange ( AuthorizationManagementClient . RoleDefinitions . ListWithFilters ( parameters ) . RoleDefinitions . Select ( r => r . ToPSRoleDefinition ( ) ) ) ;
93
+ result . AddRange ( AuthorizationManagementClient . RoleDefinitions . List ( item => item . Name == name ) . Select ( r => r . ToPSRoleDefinition ( ) ) ) ;
99
94
100
95
return result ;
101
96
}
@@ -160,7 +155,8 @@ public PSRoleAssignment CreateRoleAssignment(FilterRoleAssignmentsOptions parame
160
155
public List < PSRoleAssignment > FilterRoleAssignments ( FilterRoleAssignmentsOptions options , string currentSubscription )
161
156
{
162
157
List < PSRoleAssignment > result = new List < PSRoleAssignment > ( ) ;
163
- ListAssignmentsFilterParameters parameters = new ListAssignmentsFilterParameters ( ) ;
158
+ string assignedToPrincipalId = null ;
159
+ string principalId = null ;
164
160
165
161
PSADObject adObject = null ;
166
162
if ( options . ADObjectFilter . HasFilter )
@@ -179,21 +175,21 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
179
175
throw new InvalidOperationException ( ProjectResources . ExpandGroupsNotSupported ) ;
180
176
}
181
177
182
- parameters . AssignedToPrincipalId = adObject . Id ;
178
+ assignedToPrincipalId = adObject . Id . ToString ( ) ;
183
179
}
184
180
else
185
181
{
186
- parameters . PrincipalId = string . IsNullOrEmpty ( options . ADObjectFilter . Id ) ? adObject . Id : Guid . Parse ( options . ADObjectFilter . Id ) ;
182
+ principalId = string . IsNullOrEmpty ( options . ADObjectFilter . Id . ToString ( ) ) ? adObject . Id . ToString ( ) : options . ADObjectFilter . Id ;
187
183
}
188
184
189
- var tempResult = AuthorizationManagementClient . RoleAssignments . List ( parameters ) ;
190
- result . AddRange ( tempResult . RoleAssignments . FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
185
+ var tempResult = AuthorizationManagementClient . RoleAssignments . List ( false , principalId , assignedToPrincipalId ) ;
186
+ result . AddRange ( tempResult . FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
191
187
. ToPSRoleAssignments ( this , ActiveDirectoryClient , options . ExcludeAssignmentsForDeletedPrincipals ) ) ;
192
188
193
- while ( ! string . IsNullOrWhiteSpace ( tempResult . NextLink ) )
189
+ while ( ! string . IsNullOrWhiteSpace ( tempResult . NextPageLink ) )
194
190
{
195
- tempResult = AuthorizationManagementClient . RoleAssignments . ListNext ( tempResult . NextLink ) ;
196
- result . AddRange ( tempResult . RoleAssignments . FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
191
+ tempResult = AuthorizationManagementClient . RoleAssignments . ListNext ( tempResult . NextPageLink ) ;
192
+ result . AddRange ( tempResult . FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
197
193
. ToPSRoleAssignments ( this , ActiveDirectoryClient , options . ExcludeAssignmentsForDeletedPrincipals ) ) ;
198
194
}
199
195
@@ -206,9 +202,7 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
206
202
else if ( ! string . IsNullOrEmpty ( options . Scope ) )
207
203
{
208
204
// Filter by scope and above directly
209
- parameters . AtScope = true ;
210
-
211
- var tempResult = AuthorizationManagementClient . RoleAssignments . ListForScope ( options . Scope , parameters ) ;
205
+ var tempResult = AuthorizationManagementClient . RoleAssignments . ListForScope ( options . Scope , true , principalId , assignedToPrincipalId ) ;
212
206
result . AddRange ( tempResult . FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
213
207
. ToPSRoleAssignments ( this , ActiveDirectoryClient , options . ExcludeAssignmentsForDeletedPrincipals ) ) ;
214
208
@@ -221,15 +215,15 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
221
215
}
222
216
else
223
217
{
224
- var tempResult = AuthorizationManagementClient . RoleAssignments . List ( parameters ) ;
225
- result . AddRange ( tempResult . RoleAssignments
218
+ var tempResult = AuthorizationManagementClient . RoleAssignments . List ( false , principalId , assignedToPrincipalId ) ;
219
+ result . AddRange ( tempResult
226
220
. FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
227
221
. ToPSRoleAssignments ( this , ActiveDirectoryClient , options . ExcludeAssignmentsForDeletedPrincipals ) ) ;
228
222
229
- while ( ! string . IsNullOrWhiteSpace ( tempResult . NextLink ) )
223
+ while ( ! string . IsNullOrWhiteSpace ( tempResult . NextPageLink ) )
230
224
{
231
- tempResult = AuthorizationManagementClient . RoleAssignments . ListNext ( tempResult . NextLink ) ;
232
- result . AddRange ( tempResult . RoleAssignments
225
+ tempResult = AuthorizationManagementClient . RoleAssignments . ListNext ( tempResult . NextPageLink ) ;
226
+ result . AddRange ( tempResult
233
227
. FilterRoleAssignmentsOnRoleId ( AuthorizationHelper . GetRoleDefinitionFullyQualifiedId ( currentSubscription , options . RoleDefinitionId ) )
234
228
. ToPSRoleAssignments ( this , ActiveDirectoryClient , options . ExcludeAssignmentsForDeletedPrincipals ) ) ;
235
229
}
0 commit comments