gpt4 book ai didi

c# - 用于查找用户是否启用了 MFA 的 Azure AD Batch 服务 API

转载 作者:行者123 更新时间:2023-12-03 06:45:27 25 4
gpt4 key购买 nike

当我尝试使用 AcquireTokenByUsernamePassword 对 Azure Batch 帐户验证 AAD 用户身份时,如果用户启用了 MFA,则需要一些时间(大约 30-40 秒)才能接收 MsalUiRequiredException AADSTS50076不幸的是,这会让用户等待,并出现带有“切换到”和“重试”选项的“不太有用”提示。

我想事先知道用户需要经过 MFA,以便我可以将他重定向到交互流程 ( AcquireTokenInteractive )。

有没有办法知道用户是否启用了 MFA 标志? (我可以找到 MS Graph API 的一个,但不符合我的要求)。

最佳答案

注意,您无法使用 Azure Batch Service API 获取用户的 MFA 状态。您可以在此 MS Doc 中找到 Azure Batch Service API 支持的操作.

要通过 API 了解用户的MFA 状态,您只能使用 Microsoft Graph API。

我尝试通过 Graph Explorer 在我的环境中重现相同的内容并得到如下结果:

我运行了以下查询,通过使用 UPN 进行过滤来了解特定用户的 MFA 状态:

GET https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails?$filter=userPrincipalName eq 'User_UPN'

回应:

enter image description here

c# 代码示例:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var credentialUserRegistrationDetails = await graphClient.Reports.CredentialUserRegistrationDetails
.Request()
.Filter("userPrincipalName eq 'User_UPN'")
.GetAsync();

如果您想获取启用了 MFA所有用户,您可以使用以下查询:

GET https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails?$filter=isMfaRegistered eq true 

回应:

enter image description here

c# 代码示例:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var credentialUserRegistrationDetails = await graphClient.Reports.CredentialUserRegistrationDetails
.Request()
.Filter("isMfaRegistered eq true")
.GetAsync();

关于c# - 用于查找用户是否启用了 MFA 的 Azure AD Batch 服务 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74153273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com