我在Azure AD中創建了應用程序,並翻轉了多租戶開關以使應用程序成爲多租戶應用程序。創建多租戶天青AD應用程序的服務主體以在其他AAD租戶中公開其權限
然後,我按照文章How to sign in any Azure Active Directory (AD) user using the multi-tenant application pattern中列出的步驟將其他Azure AD租戶的用戶登錄到我的多租戶應用程序。
代碼看起來像如下
string aadInstance = "https://login.microsoftonline.com/{0}";
string tenant = "common";
string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant);
Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext context = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority);
AuthenticationResult result = await context.AcquireTokenAsync("https://XXXX.onmicrosoft.com/TodoListServiceMT", AppIdOfAppInDifferentTenant, new Uri("https://localhost:44399/"), new PlatformParameters(PromptBehavior.Always));
但認證過程中,我一直運行到下面的錯誤..
AADSTS65005:客戶端應用程序已請求訪問資源 「https://XXXX.onmicrosoft.com/TodoListServiceMT」 。這個請求 失敗,因爲它 requiredResourceAccess列表中的客戶端沒有指定該資源
對錯誤的修正要求我在其他Azure的AD租戶添加權限爲我的多租戶應用程序在我的客戶端應用程序。
但我無法找到我的多租戶應用程序在配置權限屏幕在我的客戶端應用程序在其他Azure AD租戶。我在該列表中看到的所有內容都是Azure AD Graph,ARM和Azure Active Directory。
有沒有人成功嘗試過這種方法?在其他Azure AD租戶中公開我的多租戶應用程序需要做些什麼?
租戶,在這裏工作的應用程序和資源的基本輪廓..
Tenant A
-> Multi-tenant App, resource id(App Id URI)-"https://XXXX.onmicrosoft.com/TodoListServiceMT"
Tenant B
-> Client App (AppIdOfAppInDifferentTenant)
爲了驗證,我在租戶b。使用管理員用戶
我嘗試添加了AppIdOfAppInDifferentTenant到多-tenant應用程序清單的已知客戶端應用程序部分,但只能在同一租戶中添加應用程序的Ids應用程序。
解決方案
我仍然不知道爲什麼我的代碼是不是能夠產生使用 一個同意 提示註冊成功的SP,但我試圖同新發布的Azure Active Directory V2 PowerShell Module 和它爲我工作。
不同承租人在 中創建多租戶應用程序的SP的命令順序如下。
Connect-AzureAD -TenantId "TenantId as Guid"
New-AzureADServicePrincipal -AppId "Client/Application Id of the multi tenant application"
一旦命令成功完成,多租戶應用程序將 開始在客戶端的「必需的權限」屏幕 應用
您能否在這裏描述不同的應用程序和租戶?例如:租戶A:客戶端應用程序1,資源應用程序1。租戶B:用戶1.客戶端應用程序1需要調用資源應用程序1.來自租戶B的用戶1正嘗試登錄到客戶端應用程序1,並收到客戶端應用程序1尚未將資源應用程序1註冊爲必需的資源訪問權限。 –