2016-04-26 96 views
0

我從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

是的,但我看傑弗裏給你的答案:) –

回答

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。 –

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

+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