Azure AD 多租户环境中是否始终需要管理员同意?

Is Admin consent always required in an Azure AD Multi tenant environment?

环境配置为多租户方式。 'AppName' 是一个普通 AD 中的应用程序注册,它专门用于为来自不同租户的用户提供对单一环境的访问权限。为了便于描述,将多租户称为 AD1、AD2 和 AD3。

当来自这些 AD 之一的用户(没有管理员权限)首次登录时,会显示此消息。

AppName needs permission to access resources in your organization that only an admin can grant

此外,在应用程序异常记录中我可以看到以下错误

Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolException: "OpenIdConnectMessage.Error was not null, indicating an error. Error: 'access_denied'. Error_Description (may be empty): 'AADSTS650056: Misconfigured application. This could be due to one of the following: The client has not listed any permissions for 'AAD Graph' in the requested permissions in the client's application registration. Or, The admin has not consented in the tenant. Or, Check the application identifier in the request to ensure it matches the configured client application identifier. Please contact your admin to fix the configuration or consent on behalf of the tenant.

前提是 AD1 的用户要成功访问环境,AD1 的管理员用户必须先登录并授予管理员访问权限。 "common AD" 应用注册配置如下。

应用注册中支持的账户类型选项设置为

Accounts in any organizational directory (Any Azure AD directory - Multitenant)

唯一的API权限如下图所示。状态 "Granted for ...." 仅指租户 ID 所在的 "common AD" - 它不会授予管理员对 any AD 的同意。

代码中使用的技术是 ADAL.Net OpenIDConnect。我们正在使用:https://login.microsoftonline.com/common (V1.0) 端点。

在下面显示的代码段中,在此 url 中找到在我们的案例中设置的唯一 API 权限。'Admin Consent Required' 设置为 'No'。

这就是让我失望的原因。为什么会弹出 message/error?是否需要管理员同意 总是 因为这是一个多租户场景?此管理员是否同意在普通 AD 和多租户 AD 之间建立信任?

是的。在多租户的情况下,管理员需要加入他们的租户。只有在入职流程之后,用户才能登录。此外,屏幕截图中显示的管理员同意与租赁类型无关或取决于租赁类型,它是特定于权限的。应用程序权限和一些委托权限需要管理员同意。

https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant#understand-user-and-admin-consent

https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/2-WebApp-graph-user/2-3-Multi-Tenant/README.md