我在Azure AD中创建了一个应用程序,并翻转了多租户开关,使该应用程序成为多租户。
然后,我按照文章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 list
该错误的修复程序要求我在其他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 添加到多租户应用的应用清单的 knownclientapplications 部分,但只能在同一租户中添加应用ID应用。
解决方案
我仍然不知道为什么我的代码无法生成同意 提示成功注册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"
命令成功完成后,多租户应用程序将会 开始显示在客户端的“必需权限”屏幕中 应用
答案 0 :(得分:1)
一般来说,您可以尝试使用租户2中的帐户,在租户1中登录您的应用程序,成功登录后,您的应用程序将自动添加到租户2中。您可以尝试按照以下步骤操作:
答案 1 :(得分:0)
Gary Liu的回答大多是正确的,并概述了如何在租户B中创建服务主体。完成后,您应该能够: