public async Task <IReadOnlyList <WebAccount> > FindAllWebAccountsAsync(WebAccountProvider provider, string clientID) { using (_logger.LogBlockDuration("WAM:FindAllWebAccountsAsync:")) { if (_logger.IsLoggingEnabled(LogLevel.Verbose)) { _logger.VerbosePii(provider.ToLogString(true), provider.ToLogString(false)); } // Win 10 RS3 release and above if (!ApiInformation.IsMethodPresent( "Windows.Security.Authentication.Web.Core.WebAuthenticationCoreManager", "FindAllAccountsAsync")) { _logger.Info("[WamProxy] FindAllAccountsAsync method does not exist (it was introduced in Win 10 RS3). " + "Returning 0 broker accounts. "); return(Enumerable.Empty <WebAccount>().ToList()); } FindAllAccountsResult findResult = await WebAuthenticationCoreManager.FindAllAccountsAsync(provider, clientID); // This is expected to happen with the MSA provider, which does not allow account listing if (findResult.Status != FindAllWebAccountsStatus.Success) { var error = findResult.ProviderError; _logger.Info($"[WAM Proxy] WebAuthenticationCoreManager.FindAllAccountsAsync failed " + $" with error code {error.ErrorCode} error message {error.ErrorMessage} and status {findResult.Status}"); return(Enumerable.Empty <WebAccount>().ToList()); } _logger.Info($"[WAM Proxy] FindAllWebAccountsAsync returning {findResult.Accounts.Count()} WAM accounts"); return(findResult.Accounts); } }
public static async Task <IReadOnlyList <WebAccount> > FindAllAccountsAsync(WebAccountProvider provider, string clientID, ICoreLogger logger) { FindAllAccountsResult findResult = await WebAuthenticationCoreManager.FindAllAccountsAsync(provider, clientID); // This is expected to happen with the MSA provider, which does not allow account listing if (findResult.Status != FindAllWebAccountsStatus.Success) { var error = findResult.ProviderError; logger.Info($"[WAM Proxy] WebAuthenticationCoreManager.FindAllAccountsAsync failed " + $" with error code {error.ErrorCode} error message {error.ErrorMessage} and status {findResult.Status}"); return(Enumerable.Empty <WebAccount>().ToList()); } logger.Info($"[WAM Proxy] FindAllWebAccountsAsync returning {findResult.Accounts.Count()} WAM accounts"); return(findResult.Accounts); }