【问题标题】:ADAL Authentication Error Multi-TenantADAL 身份验证错误多租户
【发布时间】:2023-03-11 16:30:02
【问题描述】:

我从 GIT 中获取了多租户的示例代码。 https://github.com/OfficeDev/O365-WebApp-MultiTenant

https://manage.windowsazure.com/ 中,我将多租户启用为是。但是,当我尝试使用其他组织登录时,我收到如下错误。

来自身份提供者“https://sts.windows.net/xxxxxxxxxxxxxxxxxxxxxxxxxxx/”的用户帐户“vtest@someconsuting.onmicrosoft.com”在租户“我的测试应用程序”中不存在,并且无法访问该租户中的应用程序“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”。需要先将该帐户添加为租户中的外部用户。注销并使用其他 Azure Active Directory 用户帐户重新登录。

我该如何解决这个问题??

【问题讨论】:

  • 你用什么网址登录?
  • 你是指 api 请求还是我的网络应用程序 url?
  • 是的,但我看到杰弗里给了你答案:)

标签: c# azure active-directory office365


【解决方案1】:

我终于找到了解决问题的方法。从这个网址https://github.com/dream-365/OfficeDev-Samples/blob/master/samples/Office365DevQuickStart/AspNetMvc-MultiTenant/

我将以下文件复制到我的项目中

TokenCacheDBContext.cs

SqlDBTokenCache.cs

ServiceConstants.cs

App_Start/Startup.auth.cs

我运行了该项目,但遇到了 Office365AssertedFailedException 的一个错误。为此,我又创建了一个类文件,例如

Office365AssertedFailedException.cs

我再次重建代码并获得了成功。现在我可以使用多租户登录了。

【讨论】:

  • 很高兴您可以使用我的示例代码来解决这个问题,我已经在这个示例中重写了 TokenCache。
【解决方案2】:

请确保您的授权网址是“https://login.windows.net/common”。

如果您的权限网址是“https://login.windows.net/{tenant_id}”,您将收到如下错误:

要解决此问题,请在 Startup.Auth.cs 中将授权 url 配置为“https://login.windows.net/common”。

    var authority = string.Format("{0}/{1}", ServiceConstants.AzureADEndPoint, "common");

    var options = new OpenIdConnectAuthenticationOptions {
        ClientId = OAuthSettings.ClientId,
        Authority = authority,
        TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters {
            ValidateIssuer = false
        }
    };

sample Startup.Auth.cs

【讨论】:

  • 我在登录页面上收到一个新错误 IOException: Unable to get document from: api.office.com/discovery/v1.0/me/common/.well-known/…
  • 我试图解决该错误,但又遇到类似这样的错误......“在 enukesoftware.onmicrosoft.com 目录中找不到标识符为 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx 的应用程序”
  • 再次获取 IO 异常...IOException: Unable to get document from: api.office.com/discovery/v1.0/me/common/.well-known/...
  • ServiceConstants.AzureADEndPoint = "login.windows.net";,在你的情况下,你使用了 "api.office.com/discovery/v1.0/me";
  • 现在它正在重定向到 Office 365,但出现另一个错误,例如 .. Microsoft.IdentityModel.Clients.ActiveDirectory.dll 中发生了“Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException”类型的异常,但未在用户代码中处理附加信息:authority_not_in_valid_list:'authority'不在有效地址列表中
【解决方案3】:

我有同样的问题。刚刚换了

    string authorityUri = "https://login.microsoftonline.net/common/";

    string authorityUri = "https://login.windows.net/common";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 2021-11-17
    • 1970-01-01
    • 2022-01-20
    • 2016-12-06
    相关资源
    最近更新 更多