c# - AADSTS50020 来自身份提供商“live.com”的用户帐户“xxx@zbc.com”在租户“xx-xx-xx-xx”中不存在 C# Winforms 中的错误
问题描述
我需要AAD B2C Authentication
在C# Winforms
应用程序中实现。
我已经在portal.azure.com中注册了我的应用程序,还添加了用户,并在应用程序身份验证中添加了“移动和桌面应用程序”Azure AD B2C
User Flows(Sign up and sign in, Password Reset, Profile Editing)
xxx@zbc.com
Platform
我在我的Login
屏幕中使用以下代码。
string ClientId = "9xXxXxXx-7XxX-4XxX-9XxX-aXxXxXxXxXxX";
string Tenant = "exXxXxXx-9XxX-4XxX-XxX-8XxXxXxXxXxX";
IPublicClientApplication PublicClientApp;
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId)
.WithRedirectUri("https://aaa.xxx.com/oauth2/nativeclient")
.WithDefaultRedirectUri()
.WithAuthority(AzureCloudInstance.AzurePublic, Tenant)
.Build();
string token = PublicClientApp.UserTokenCache;
private async void button1_Click(object sender, EventArgs e)
{
var _scopes = new string[] { "user.read" }.AsEnumerable();
var authResult = await PublicClientApp.AcquireTokenInteractive(_scopes)
.WithUseEmbeddedWebView(true)
.ExecuteAsync();
}
当我运行代码时,我得到了用于登录的弹出窗口,在 此处输入图像描述
我已经输入了电子邮件,然后在单击登录时输入了密码Wrong Password
。然后我从同一页面重置密码并Sign In
再次尝试。现在新的错误消息像......
AADSTS50020: User account 'xxx@zbc.com' from identity provider 'live.com' does not exist in
tenant 'XXX' and cannot access the application '9xXxXxXx-7XxX-4XxX-9XxX-aXxXxXxXxXxX'(XXX)
in that tenant. The account needs to be added as an external user in the tenant first.
Sign out and sign in again with a different Azure Active Directory user account. c# winforms
请给我一个解决这个问题的方法......在此先感谢......
解决方案
错误指出帐户“xxx@zbc.com”不是注册应用程序的 AAD 租户 (XXX) 的一部分。
xxx@zbc.com - 同样来自错误 - 用户似乎是真实帐户(@outlook.com、@hotmail.com 等)
所以要解决这个问题 -
登录到您已在其中注册应用程序的租户 (XXX)。
将您的真实帐户 (xxx@zbc.com) 作为外部用户添加到租户。
有关添加外部帐户的详细步骤,您可以参考以下文章
或者,您可以更改应用程序以支持租户以外的帐户 (XXX)
目前,从错误中 - 我假设您的配置设置为仅在此组织目录中的帐户
您必须将其更改为第三个选项: 任何组织目录中的帐户
这可以更改 Azure -> Azure Active Directory -> 管理 -> 应用注册 -> 应用名称 -> 支持的帐户类型
您可以参考以下链接了解详细步骤:
https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-modify-supported-accounts
推荐阅读
- android - 使用 4K 相机设备中存在的内置面部检测可以检测到多远的面部?
- r - 在 R 中使用 jsonlite 时,如何指定仅将某些条目视为数组?
- python - Python -Flask 我想以干净的格式在 html 页面上显示 Mongodb 中存在的数据
- c++ - 我怎么知道我是在开发 c++/cx 还是 c++/WinRT UWP 应用程序?
- javascript - 从 div 卸载页面上的 jQuery / JavaScript
- haskell - 什么是(复合)效果(可能表示为 Monad+Monad 变形金刚)?准确、清晰、简短的答案/定义?
- python-3.x - 从python 3中字节的字符串表示中检索字节
- android - 像 Temple Run 胸部一样的动画矢量 drawable
- jquery - 调用此链接的正确方法
- python-3.x - 在 Raspberry [python] 中安装 SpeechRecognition