ADAL身份验证错误多租户

时间:2016-04-26 13:28:18

标签: c# azure active-directory office365

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

https://manage.windowsazure.com/中我启用了MULTI-TENANT为YES。但是当我尝试使用不同的组织登录时,我会收到如下错误。

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

我该如何解决这个问题?

3 个答案:

答案 0 :(得分: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

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

答案 1 :(得分:0)

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

如果您的权限网址为“https://login.windows.net/ {tenant_id}”,则会收到如下错误: enter image description here

要解决此问题,请在Startup.Auth.cs中将权限网址配置为“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

答案 2 :(得分:0)

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

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

使用

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