public async Task <List <Beta.AuthenticationContextClassReference> > ListAuthenticationContextClassReferencesAsync() { List <Beta.AuthenticationContextClassReference> allAuthenticationContextClassReferences = new List <Beta.AuthenticationContextClassReference>(); try { Beta.IConditionalAccessRootAuthenticationContextClassReferencesCollectionPage authenticationContextClassreferences = await _graphServiceClient.Identity.ConditionalAccess.AuthenticationContextClassReferences.Request().GetAsync(); if (authenticationContextClassreferences != null) { allAuthenticationContextClassReferences = await ProcessIAuthenticationContextClassReferenceRootPoliciesCollectionPage(authenticationContextClassreferences); } } catch (ServiceException e) { Console.WriteLine($"We could not retrieve the existing ACRs: {e}"); if (e.InnerException != null) { var exp = (MicrosoftIdentityWebChallengeUserException)e.InnerException; throw exp; } throw e; } return(allAuthenticationContextClassReferences); }
private async Task <List <Beta.AuthenticationContextClassReference> > ProcessIAuthenticationContextClassReferenceRootPoliciesCollectionPage(Beta.IConditionalAccessRootAuthenticationContextClassReferencesCollectionPage authenticationContextClassreferencesPage) { List <Beta.AuthenticationContextClassReference> allAuthenticationContextClassReferences = new List <Beta.AuthenticationContextClassReference>(); try { if (authenticationContextClassreferencesPage != null) { var pageIterator = PageIterator <Beta.AuthenticationContextClassReference> .CreatePageIterator(_graphServiceClient, authenticationContextClassreferencesPage, (authenticationContextClassreference) => { Console.WriteLine(PrintAuthenticationContextClassReference(authenticationContextClassreference)); allAuthenticationContextClassReferences.Add(authenticationContextClassreference); return(true); }); await pageIterator.IterateAsync(); while (pageIterator.State != PagingState.Complete) { await pageIterator.ResumeAsync(); } } } catch (ServiceException e) { Console.WriteLine($"We could not process the authentication context class references list: {e}"); return(null); } return(allAuthenticationContextClassReferences); }