在Office Add-ins中,我可以知道用户属于哪个租户吗?

In Office Add-ins, can i know which tenant the user belongs to?

我尝试使用 mailbox.makeEwsRequestAsync but looks like it doesn't support the GetUserSettings operation 获取它。

Exchange On Premise (2013+) 和现在的个人 Microsoft 帐户 (outlook.com) 也支持 Office Outlook Web 加载项。在这些情况下,没有租户的概念,所以我认为您无法检索 TenantId.

如果您的 Office 插件使用 Azure AD,则 TenantId 将成为 the claims but your add-in will be only compatible to Office 365 accounts (except if you use the new Azure v2.0 model 的一部分。真正的负面影响是您的用户必须使用他们的 Office365 帐户在加载项中进行身份验证。

我想我找到了解决方法。

获取getUserIdentityTokenAsync. It is a JWT Token that can be deserialized see for example this site返回的token。

反序列化的 JSON 的各个字段中都存在租户 ID(见附件中的红色方块)。我只对一个 Office365 租户进行了测试。