5252 "The output includes credentials that you must protect. Be sure that you do not include these credentials in "
5353 "your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli" )
5454
55- CLASSIC_ADMINISTRATOR_WARNING = (
56- "Azure classic subscription administrators will be retired on August 31, 2024. "
57- "After August 31, 2024, all classic administrators risk losing access to the subscription. "
58- "Delete classic administrators who no longer need access or assign an Azure RBAC role for fine-grained access "
59- "control. Learn more: https://go.microsoft.com/fwlink/?linkid=2238474" )
60-
6155logger = get_logger (__name__ )
6256
6357# pylint: disable=too-many-lines, protected-access
@@ -237,16 +231,10 @@ def list_role_assignments(cmd, # pylint: disable=too-many-locals, too-many-bran
237231 role = None ,
238232 resource_group_name = None , scope = None ,
239233 include_inherited = False ,
240- show_all = False , include_groups = False , include_classic_administrators = False ,
234+ show_all = False , include_groups = False ,
241235 fill_role_definition_name = True , fill_principal_name = True ):
242236 if assignee and assignee_object_id :
243237 raise CLIError ('Usage error: Provide only one of --assignee or --assignee-object-id.' )
244- if assignee_object_id and include_classic_administrators :
245- raise CLIError ('Usage error: --assignee-object-id cannot be used with --include-classic-administrators. '
246- 'Use --assignee instead.' )
247-
248- if include_classic_administrators :
249- logger .warning (CLASSIC_ADMINISTRATOR_WARNING )
250238
251239 graph_client = _graph_client_factory (cmd .cli_ctx )
252240 authorization_client = _auth_client_factory (cmd .cli_ctx , scope )
@@ -268,8 +256,6 @@ def list_role_assignments(cmd, # pylint: disable=too-many-locals, too-many-bran
268256 include_inherited , include_groups )
269257
270258 results = todict (assignments ) if assignments else []
271- if include_classic_administrators :
272- results += _backfill_assignments_for_co_admins (cmd .cli_ctx , authorization_client , assignee )
273259
274260 if not results :
275261 return []
@@ -471,53 +457,6 @@ def list_role_assignment_change_logs(cmd, start_time=None, end_time=None): # py
471457 return result
472458
473459
474- def _backfill_assignments_for_co_admins (cli_ctx , auth_client , assignee = None ):
475- worker = MultiAPIAdaptor (cli_ctx )
476- co_admins = auth_client .classic_administrators .list () # known swagger bug on api-version handling
477- co_admins = [x for x in co_admins if x .email_address ]
478- graph_client = _graph_client_factory (cli_ctx )
479- if assignee : # apply assignee filter if applicable
480- if is_guid (assignee ):
481- try :
482- result = _get_object_stubs (graph_client , [assignee ])
483- if not result :
484- return []
485- assignee = _get_displayable_name (result [0 ]).lower ()
486- except ValueError :
487- pass
488- co_admins = [x for x in co_admins if assignee == x .email_address .lower ()]
489-
490- if not co_admins :
491- return []
492-
493- result , users = [], []
494- for i in range (0 , len (co_admins ), 10 ): # graph allows up to 10 query filters, so split into chunks here
495- upn_queries = ["userPrincipalName eq '{}'" .format (x .email_address )
496- for x in co_admins [i :i + 10 ]]
497- temp = list (list_users (graph_client , query_filter = ' or ' .join (upn_queries )))
498- users += temp
499- upns = {u ['userPrincipalName' ]: u [ID ] for u in users }
500- for admin in co_admins :
501- na_text = 'NA(classic admins)'
502- email = admin .email_address
503- result .append ({
504- 'id' : na_text ,
505- 'name' : na_text ,
506- })
507- properties = {
508- 'principalId' : upns .get (email ),
509- 'principalName' : email ,
510- 'roleDefinitionName' : admin .role ,
511- 'roleDefinitionId' : 'NA(classic admin role)' ,
512- 'scope' : '/subscriptions/' + auth_client ._config .subscription_id
513- }
514- if worker .old_api :
515- result [- 1 ]['properties' ] = properties
516- else :
517- result [- 1 ].update (properties )
518- return result
519-
520-
521460def _get_displayable_name (graph_object ):
522461 # user
523462 if 'userPrincipalName' in graph_object :
0 commit comments