我们创建了 AAD 和 Live 用户可以登录的融合应用程序。我们想知道拥有 Live 或 AAD 帐户的登录用户。
IdToken/Graph API 中是否有任何 API 或值可用于区分 MSA 或 AAD。
最佳答案
您登录后收到的 Id token 包含 tid
声明中的租户 ID。
例如:
b9419818-09af-49c2-b0c3-653adc1f376e
GUID 是租户的 ID。对于 MSA,该值将为:
9188040d-6c67-4c5b-b112-36a304b66dad
来源:Azure Active Directory v2.0 tokens reference
A GUID that represents the Azure AD tenant that the user is from. For work and school accounts, the GUID is the immutable tenant ID of the organization that the user belongs to. For personal accounts, the value is 9188040d-6c67-4c5b-b112-36a304b66dad. The profile scope is required in order to receive this claim.
您还可以从 iss
声明(即颁发者)获取此 ID。
关于authentication - 如何区分 Microsoft MSA 和 AAD 帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48515074/