简体   繁体   English

来自非托管Azure AD目录的用户是否可以登录位于其他目录中的Azure AD多租户应用程序?

[英]Can users from an unmanaged Azure AD directory, sign into an Azure AD multi-tenant application which resides in a different directory?

I'm trying out Azure AD B2B capabilities for my company. 我正在为我的公司尝试Azure AD B2B功能。 I have tried to invite external users through the portal and by using https://graph.microsoft.com/beta/invitations . 我试图通过门户网站和https://graph.microsoft.com/beta/invitations邀请外部用户。 Users are successfully invited and added to our directory in both scenarios. 在两种方案中,成功邀请用户并将其添加到我们的目录中。 Login works for social accounts (that then use a Microsoft account). 登录适用于社交帐户(然后使用Microsoft帐户)。 If it's a non-social account aka contoso.com, that does not have an Azure AD from before, I get an access_denied when our application tries to log in the user. 如果它是一个非社交帐户,也就是contoso.com,它之前没有Azure AD,当我们的应用程序尝试登录用户时,我会获得access_denied。 If I try to force a consent flow, I get the following message: 如果我试图强制同意流程,我收到以下消息:

AADSTS65005: The application zzz is currently not supported for your company aaa.no. AADSTS65005:您的公司aaa.no目前不支持应用程序zzz。 Your company is currently in an unmanaged state and needs an Administrator to claim ownership of the company by DNS validation of aaa.no before the application zzz can be provisioned. 您的公司目前处于非托管状态,需要管理员通过DNS验证aaa.no来声明对公司的所有权,然后才能配置应用程序zzz。

We have a lot of small companies as customers and it seems unreasonable that they all have to make the Azure AD directory managed before their users can use our applications. 我们有很多小公司作为客户,他们都必须在用户可以使用我们的应用程序之前管理Azure AD目录似乎是不合理的。 It's supposed to be seamless according to Microsoft : 根据微软的说法,这应该是无缝的:

Seamless: The partner companies who need access to your corporate apps do not need to have Azure AD. 无缝:需要访问公司应用程序的合作伙伴公司不需要Azure AD。 Azure AD B2B collaboration provides a simple user sign-up experience to provide these partners with immediate access to your apps. Azure AD B2B协作提供简单的用户注册体验,为这些合作伙伴提供对您的应用的即时访问。

If they can sign up and create both their user and the directory, why can't they give the application they have been invited to consent for sign-in (Sign in and read user profile delegate permissions is required by the application)? 如果他们可以注册并创建他们的用户和目录,为什么他们不能给他们被邀请的应用程序同意登录(应用程序需要登录和读取用户配置文件委派权限)?

We already allow companies with their own managed Azure AD to use their users in our applications. 我们已经允许拥有自己的托管Azure AD的公司在我们的应用程序中使用他们的用户。 We get a Global Administrator to give admin consent to our applications so they can sign in users and read directory data. 我们让全球管理员给予我们的应用程序管理员同意,以便他们可以登录用户并读取目录数据。 These users are not added to our directory and it works perfectly. 这些用户没有添加到我们的目录中,它完美地运行。

Also, If I go to the new portal as the invited user, I can see that the domain aaa.no is verified, but I cannot set it as primary. 此外,如果我作为受邀用户转到新门户,我可以看到域aaa.no已经过验证,但我无法将其设置为主要。

Other things I have tried that did not work: Upgraded to newest ADAL version, tried to create application in https://apps.dev.microsoft.com and use that, tried to set permissions in old azure portal (seems to be a bug in the new portal where permissions does not show up in the manifest) and tried to make the application single tenant. 我试过的其他东西不起作用:升级到最新的ADAL版本,尝试在https://apps.dev.microsoft.com中创建应用程序并使用它,试图在旧的azure门户中设置权限(似乎是一个bug在新门户中,权限未显示在清单中)并尝试使应用程序成为单个租户。 Nothing works. 什么都行不通。

The most prevalent guidance and examples for writing Azure AD multi-tenant apps recommend using the common endpoint instead of tenant specific endpoint. 编写Azure AD多租户应用程序的最流行指南和示例建议使用公共端点而不是租户特定端点。

Common endpoint: https://login.microsoftonline.com/common/oauth2/authorize
Tenant specific endpoint: https://login.microsoftonline.com/company.com/oauth2/authorize

The common endpoint allows users from any tenant to log in. It achieves this by doing tenant discovery, meaning that, based on the user's email, it'll automatically redirect the user to their tenant endpoint. 公共端点允许来自任何租户的用户登录。它通过进行租户发现来实现此目的,这意味着,基于用户的电子邮件,它将自动将用户重定向到其租户端点。 However, this also means that user@company.com will always be signed-in as an employee of company.com and never as a guest of some other company they've been added as a guest to via the B2B collaboration feature - In short, the common endpoint doesn't support guests. 但是,这也意味着user@company.com将始终以company.com的员工身份登录,并且永远不会作为其他公司的访客,他们已通过B2B协作功能添加为访客 - 简而言之, 公共端点不支持访客。

The tenant specific endpoint on the other hand, only allows users from that tenant to log in. While it doesn't do tenant discovery, it still allows users from other tenants to attempt to sign in, but will then check to see if they've been added as guests to the tenant. 另一方面,租户特定端点仅允许来自该租户的用户登录。虽然它不进行租户发现,但它仍然允许来自其他租户的用户尝试登录,但是然后将检查他们是否'已被添加为租客的客人。 If they haven't, the sign in will fail - In short, guests users (users added via the B2B collaboration feature), only work in the tenant specific endpoint. 如果没有,则登录将失败 - 简而言之, 来宾用户(通过B2B协作功能添加的用户)仅在租户特定端点中工作。

If you want your multi-tenant application to support guests, you'll need to do tenant discovery yourself and leverage the tenant specific endpoints rather than the common endpoint. 如果您希望多租户应用程序支持来宾,您需要自己进行租户发现并利用租户特定端点而不是公共端点。

This means that your application will need to know which Azure AD tenant is associated to each workspace/team/instance/whatever-isolation-level-in-the-all, for example: 这意味着您的应用程序需要知道哪个Azure AD租户与每个工作区/团队/实例/所有 - 隔离级别相关联,例如:

contoso.myapp.com or www.myapp.com/contoso will sign in users via login.microsoftonline.com/contoso.com

and

fabrikam.myapp.com or www.myapp.com/fabrikamwill sign in users via login.microsoftonline.com/fabrikam.com

As you can see from below, Azure support gave me the same conclusion: The common endpoint does not work for guest users. 从下面可以看到,Azure支持给了我相同的结论:公共端点不适用于访客用户。 The workaround I ended up with is to add all users as guest users in my tenant and use the tenant specific endpoint. 我最终得到的解决方法是将所有用户添加为我的租户中的访客用户并使用特定于租户的端点。 I also noticed that guest users get a different objectId than their home user, which means we needed to store the relation between guest and home user when external tenants where used to determine group membership etc. 我还注意到,访客用户获得了与其家庭用户不同的objectId,这意味着当外部租户用于确定组成员资格等时,我们需要存储访客和家庭用户之间的关系。

Here is the final response I got from Azurte support: 以下是Azurte支持的最终回复:

Symptom 症状

You are sending B2B invites for several customers to enable them to use your multi-tenant application "NameOfApplication" that has been created on the Azure AD directory nameOfTenant.onmicrosoft.com 您正在为多个客户发送B2B邀请,以使他们能够使用在Azure AD目录名称上创建的多租户应用程序“NameOfApplication”nameOfTenant.onmicrosoft.com

Invited email verified users that reside on unmanaged directories are unable to access the application with an "Access Denied" error. 驻留在非托管目录上的受邀电子邮件验证用户无法访问具有“拒绝访问”错误的应用程序。 The underlying error message : 基本错误消息:

AADSTS65005: The application NameOfApplication is currently not supported for your company .no. AADSTS65005:您的公司目前不支持应用程序NameOfApplication。 Your company is currently in an unmanaged state and needs an Administrator to claim ownership of the company by DNS validation of .no before the application NameOfApplication can be provisioned. 您的公司目前处于非托管状态,需要管理员在可以配置应用程序NameOfApplication之前通过DNS验证.no来声明对公司的所有权。

Cause 原因

The issue here lies with the endpoints being used to proceed with user authentication. 这里的问题在于端点用于继续进行用户身份验证。

In the case of b2b invites and the common tenant endpoint it is implied that tenant discovery will be used. 在b2b邀请和公共租户端点的情况下,暗示将使用租户发现。 This also means that the users will be authenticated in their original tenants and not use the guest account that was created in the tenant where the application actually exists. 这也意味着用户将在其原始租户中进行身份验证,而不使用在应用程序实际存在的租户中创建的来宾帐户。

Conclusion: the common endpoint does not, at this point in time, support guest accounts. 结论:此时,公共端点不支持访客帐户。

If tenant specific endpoints are used, then the guest accounts generated by the b2b process will be used but only users from that specific tenant will be authenticated. 如果使用租户特定端点,则将使用b2b进程生成的来宾帐户,但仅对来自该特定租户的用户进行身份验证。 This means that users from other tenants might still try to authenticate but if they haven't been added as guests to the original tenant, the authentication will fail. 这意味着来自其他租户的用户可能仍会尝试进行身份验证,但如果他们尚未作为来宾添加到原始租户,则身份验证将失败。

Conclusion: guest users (from b2b) will only work in the tenant specific endpoint 结论:访客用户(来自b2b)仅在租户特定端点中工作

Resolution 解析度

There is unfortunately no other method to resolve this matter unless by developing your application to perform a customized tenant discovery operation and from there being able to use the tenant specific endpoint for each. 遗憾的是,除非通过开发您的应用程序来执行自定义租户发现操作,并且能够使用每个租户特定端点,否则没有其他方法可以解决此问题。

Quoting from you own words: 引用你自己的话:

“…I use the tenant specific endpoint and convert all users to guests in that tenant. “...我使用特定于租户的端点并将所有用户转换为该租户中的访客。 Users in managed external tenants that we get directory read access to can then be added as guests when they become members of groups (in their tenant) that we monitor. 当我们获得目录读取访问权限的托管外部租户中的用户可以在他们成为我们监控的组(在他们的租户中)的成员时添加为访客。 That way we still allow these companies to control access to our systems from within their system. 这样我们仍然允许这些公司从他们的系统内控制对我们系统的访问。 All other users will be added as guests manually (social accounts, unmanaged external tenants, and from managed external tenants that we do not have read directory access to)…” 所有其他用户将手动添加为来宾(社交帐户,非托管外部租户以及我们没有读取目录访问权限的托管外部租户)...“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM