首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有用户名和密码的Azure AD认证,也有MFA

有用户名和密码的Azure AD认证,也有MFA
EN

Stack Overflow用户
提问于 2022-03-31 01:07:21
回答 1查看 1.1K关注 0票数 1

我使用MSAL (RPOC)和.net 4.6.1实现了Azure AD身份验证。如果用户的MFA未启用,我可以对用户进行身份验证。如果启用了它,则会收到一个错误。

代码语言:javascript
复制
**Microsoft.Identity.Client.MsalUiRequiredException: 'AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000003-0000-0000-c000-000000000000'.**

这是我正在使用的代码。

代码语言:javascript
复制
 public async Task<string> ValidateUserAsync()
    {

        string authority = string.Format("https://login.microsoftonline.com/{0}", tenant);
        string[] scopes = new string[] { "User.Read" };
        IPublicClientApplication app;
        app = PublicClientApplicationBuilder.Create(clientId)
                  .WithAuthority(authority)
                  .Build();
        var securePassword = new SecureString();
        foreach (char c in password.ToCharArray())  
            securePassword.AppendChar(c);  
        var result = await app.AcquireTokenByUsernamePassword(scopes, username, securePassword).ExecuteAsync();
        return result.IdToken;
    }

如何实现MFA?比如接收短信的代码和传递给这个?我将拥有自己的UI来接受代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-01 07:01:41

你不能。为了让用户进行MFA,他们必须在Microsoft登录页面上这样做。这是ROPC身份验证流的限制之一。我建议您使用不同的流,不要收集用户密码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71685756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档