我们正在研究 Azure AD B2C 空间中的一个用例,我们需要访问通过注册用户流程或策略注册时输入的用户的 MFA 电话号码(如下图所示)。
我们尝试探索图形端点 https://learn.microsoft.com/en-us/graph/api/phoneauthenticationmethod-get?view=graph-rest-1.0&tabs=http#http-request 来阅读此信息,但是,注意到它效果不佳,并且文档还确认它不应用于 azure ad b2c。
我们尝试向 Microsoft 提出支持案例,但被告知这是设计使然,目前支持团队在这方面无能为力。
我们还发现了一些几年前的类似帖子,例如Azure AD B2C,以编程方式获取经过 MFA 验证的电话号码,令人惊讶的是,即使多年后,该问题仍然存在且仍未解决。
出于好奇,我们发现甚至 Azure ad b2c 门户也使用旧版 graph.windows.net API 来获取此信息并将其显示在用户界面上!
如果有人知道这个问题的潜在解决方法,我们将不胜感激? 非常感谢!
在尝试多种方法并联系 Microsoft Azure 支持后,我们不得不停止,因为当前 MS graph api 无法访问使用默认用户流或使用 azure ad b2c 中的自定义策略存储的用户的 MFA 电话号码。
虽然这是一个已知问题,有望出现在产品组的路线图上,但是目前还无法确定修复的时间表。
我尝试在我的环境中重现相同的结果,并得到如下结果:
我创建了一个 Azure AD B2C 用户并启用了 MFA:
现在,我为 B2C 用户添加了身份验证方法,如下所示:
要使用 MS graph API 获取 Azure AD b2c 用户的身份验证方法或 MFA 电话号码,请使用以下查询:
GET https://graph.microsoft.com/v1.0/users/ObjectID/authentication/methods
不幸的是,我没有找到直接更新它的方法,所以摆弄了Azure门户发送的更新此电话号码的请求。我意识到他们不会更新旧的,而是使用新的 Graph API 创建一个新的 MFA PhoneMethod 条目。所以连我现在也开始做同样的事情了。
private async Task UpsertPhoneAuthenticationMethod(string newNumber, string idString)
{
var phoneRequest = new PhoneAuthenticationMethod { PhoneNumber = newNumber, PhoneType = AuthenticationPhoneType.Mobile };
var existingMethods = await _graphClient.Users[idString].Authentication.Methods.GetAsync();
if (existingMethods.Value.Any(x => x.Id == PhoneMethodGuid))
{
await _graphClient.Users[idString].Authentication.PhoneMethods[PhoneMethodGuid].PatchAsync(phoneRequest);
}
else
{
await _graphClient.Users[idString].Authentication.PhoneMethods.PostAsync(phoneRequest);
}
}
注意:我的答案总是添加 MFA 编号,即使它尚不存在。因为我找不到检索现有详细信息的方法。
现有详细信息作为元数据出现在
https://graph.windows.net/myorganization/users('user-object-id')?api-version=1.6-internal
,
...
"strongAuthenticationDetail": {
"encryptedPinHash": null,
"encryptedPinHashHistory": null,
"methods": [],
"oathTokenMetadata": [],
"requirements": [],
"phoneAppDetails": [],
"proofupTime": null,
"verificationDetail": {
"alternativePhoneNumber": null,
"email": null,
"phoneNumber": "+44 1234 557812",
"voiceOnlyPhoneNumber": null
}
},
"windowsInformationProtectionKey": []
....
}