简体   繁体   English

MS Teams 机器人上下文或功能中是否有租户名称的概念?

[英]Is there a notion of a tenant name within an MS Teams bot context or function?

In botbuilder, there's a context.activity.channelData object that my bot received.在 botbuilder 中,我的机器人收到了一个context.activity.channelData对象。 That has a tenant object which only contains an id property.它有一个仅包含id属性的tenant对象。 Is there any property or function that can return to me the name of the tenant (organization) who belongs to that id ?是否有任何财产或功能可以将属于该id的租户(组织)的名称返回给我?

Here's an example.这是一个例子。 A user works for Acme Inc. and has three MS Teams teams: Team1, Team2, and Team3.用户在Acme Inc. ,拥有三个 MS Teams 团队:Team1、Team2 和 Team3。 I can get the names of all the teams, and I can get the tenantId for "Acme Inc."我可以获得所有团队的名称,并且可以获得“Acme Inc.”的tenantId but how can I get the name of the tenant that owns those team, aka the text Acme Inc. ?但是我怎样才能得到拥有这些团队的租户的名字,也就是文本Acme Inc.

Unfortunately, you can't get that info from channelData.不幸的是,您无法从 channelData 获取该信息。

You can use GraphAPI to return the org name.您可以使用 GraphAPI 返回组织名称。 https://graph.microsoft.com/v1.0/organization?$select=displayName

https://developer.microsoft.com/en-us/graph/graph-explorer https://developer.microsoft.com/en-us/graph/graph-explorer

Here is a bot sample on how to use graph in a bot. 是一个关于如何在机器人中使用图形的机器人示例。 And here is a sample on using auth in Teams. 是在 Teams 中使用身份验证的示例。 With all that together, you should be able to get that info.综上所述,您应该能够获得该信息。

If needed at all you can get the AAD group ID from TeamsInfo.如果需要,您可以从 TeamsInfo 获取 AAD 组 ID。 Info here .信息在这里

While it's not possible to get the actual tenant name per se from channel data, what you can do in your bot is make a call to get "conversation members", in order to get a UPN for the user(s).虽然无法从频道数据中获取实际租户名称本身,但可以在机器人中执行调用以获取“对话成员”,以便为用户获取 UPN。 Here's an example in C# (I'm sure there's a Node equivalent) an that will give you properties including:这是C# 中的一个示例(我确定有一个 Node 等效项),它将为您提供属性,包括:

"userPrincipalName": "MeganB@[whatever].OnMicrosoft.com"

That might be enough for what you need?这可能足以满足您的需要?

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

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