ADAL身份验证错误多租户

ADAL身份验证错误多租户

问题描述:

我从GIT获取了多租户示例代码。 https://github.com/OfficeDev/O365-WebApp-MultiTenantADAL身份验证错误多租户

https://manage.windowsazure.com/我启用了MULTI-TENANT为YES。但是,当我尝试登录不同的组织时,我得到的错误如下。从身份提供商“https://sts.windows.net/xxxxxxxxxxxxxxxxxxxxxxxxxxx/

用户帐户“[email protected]”不存在房客“我的测试应用程序”,并在该租户不能访问应用程序“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”。该帐户需要首先作为租户中的外部用户添加。退出并使用其他Azure Active Directory用户帐户重新登录。

我该如何解决这个问题?

+0

你用什么样的网址登录? –

+0

你的意思是api请求或我的网络应用程序的网址? – user3463733

+0

是的,但我看杰弗里给你的答案:) –

终于让我找到了解决我的问题。从这个URL 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

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

+0

很高兴知道您可以使用我的示例代码来解决这个问题,我已经在这个示例中重写了TokenCache。 –

请确保您的权威网址是“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

+0

我在登录页面上得到一个新的错误为IOException:无法获取文档:https://api.office.com/discovery/v1.0/me/ common/.well-known/openid-configuration – user3463733

+0

我试图解决该错误,但得到了另一个错误,如下所示......“在目录enukesoftware.onmicrosoft中未找到带有标识符xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx的应用程序。 com“ – user3463733

+0

再次获取IO异常... IOException:无法从以下位置获取文档:api.office.com/discovery/v1.0/me/common/.well-known/... – user3463733