使用服务器端 Blazor 进行多租户 Azure 应用注册
MultiTenant Azure AppRegistration with Server Side Blazor
我在 Visual Studio 2022 年使用默认的 Blazor 服务器模板,身份验证设置为使用 Microsoft Identity Platform。
我的 Azure Active Directory 帐户中有一个 AppRegistration 设置为允许任何组织(多租户)中的帐户:
在我的 appsettings.json 文件中,我使用了正确的客户端和租户 ID:
当我 运行 应用程序时,我可以使用我的 AAD 租户中的任何帐户(或已被邀请加入我的 AAD)登录。但是,当我尝试使用来自另一个 AAD 租户的身份时,出现以下错误:
Selected user account does not exist in tenant 'TENANT NAME' and cannot access the application 'APP-REGISTRATION-ID' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account.
根据我在文档和其他文章中找到的内容,我需要使用通用端点进行登录,但是如果我将应用程序设置中的 "Domain" 更改为"common" 它没有什么区别,如果我将 "Instance" 更新为 https://login.microsoftonline.com/common/oauth2/authorize or https://login.microsoftonline.com/common/ 我得到一个例外,因为 URL 不正确。
也许默认的 Blazor 服务器模板设置为使用单租户应用程序注册?如何让它正确使用 Multitenant?
根据所选支持的帐户类型,您必须更改 值 of TenantId
在 appsettings.json 文件中。
对于Single-Tenant账户类型,应该是“your_tenant_id
对于Multitenant账户类型,应该是“organizations
"
对于多租户和个人Microsoft帐户类型,应该是“common
由于您选择了“任何组织目录中的帐户(任何 Azure AD 目录 - 多租户)”,请通过更改您的 appsettings.json 进行检查 值如下:
您的 TenantId
值必须是 organizations 并且您的 ClientId
值必须是 your_application_id.
请检查您的 Domain
值。您可以在 Azure AD 概述 页面中找到您的 域:
确保将 appsettings.json 文件中的 CallbackPath
包含在 重定向应用程序的 URI 以避免 重定向 URI 不匹配 错误。
如果对您有帮助,请查找以下参考资料。
我在 Visual Studio 2022 年使用默认的 Blazor 服务器模板,身份验证设置为使用 Microsoft Identity Platform。
我的 Azure Active Directory 帐户中有一个 AppRegistration 设置为允许任何组织(多租户)中的帐户:
在我的 appsettings.json 文件中,我使用了正确的客户端和租户 ID:
当我 运行 应用程序时,我可以使用我的 AAD 租户中的任何帐户(或已被邀请加入我的 AAD)登录。但是,当我尝试使用来自另一个 AAD 租户的身份时,出现以下错误:
Selected user account does not exist in tenant 'TENANT NAME' and cannot access the application 'APP-REGISTRATION-ID' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account.
根据我在文档和其他文章中找到的内容,我需要使用通用端点进行登录,但是如果我将应用程序设置中的 "Domain" 更改为"common" 它没有什么区别,如果我将 "Instance" 更新为 https://login.microsoftonline.com/common/oauth2/authorize or https://login.microsoftonline.com/common/ 我得到一个例外,因为 URL 不正确。
也许默认的 Blazor 服务器模板设置为使用单租户应用程序注册?如何让它正确使用 Multitenant?
根据所选支持的帐户类型,您必须更改 值 of TenantId
在 appsettings.json 文件中。
对于Single-Tenant账户类型,应该是“
your_tenant_id
对于Multitenant账户类型,应该是“
organizations
"对于多租户和个人Microsoft帐户类型,应该是“
common
由于您选择了“任何组织目录中的帐户(任何 Azure AD 目录 - 多租户)”,请通过更改您的 appsettings.json 进行检查 值如下:
您的 TenantId
值必须是 organizations 并且您的 ClientId
值必须是 your_application_id.
请检查您的 Domain
值。您可以在 Azure AD 概述 页面中找到您的 域:
确保将 appsettings.json 文件中的 CallbackPath
包含在 重定向应用程序的 URI 以避免 重定向 URI 不匹配 错误。
如果对您有帮助,请查找以下参考资料。