简体   繁体   English

如何针对Azure AD对MS Teams用户进行身份验证

[英]How to Authenticate MS Teams User Against Azure AD

I am trying to create a bot which would be deployed into MS Teams (and Skype for Business). 我正在尝试创建一个将被部署到MS Teams(和Skype for Business)中的机器人。 I see when a user interacts with the bot they are provided with a channelData.tenant.id and the Bot Framework docs say that this is the "The tenant ID for the user." 我看到当用户与漫游器进行交互时,会向他们提供一个channelData.tenant.id ,并且Bot Framework文档说这是“用户的租户ID”。 I was wondering if I can use this (or another piece of information coming from the inbound message) to authenticate the user against my Azure AD? 我想知道是否可以使用此消息(或来自入站消息的另一条信息)来根据我的Azure AD对用户进行身份验证? Also, would this require me to authenticate the user via an authentication flow like is done with the AuthBot?( https://github.com/MicrosoftDX/AuthBot ) 另外,这是否需要我像AuthBot一样通过身份验证流程对用户进行身份验证?( https://github.com/MicrosoftDX/AuthBot

Any help would be great! 任何帮助将是巨大的!

You have the tenant.id provided in channelData yes, so you could use it to make some customs requests like with Graph API. 你有tenant.id中提供channelData是的,所以你可以用它来作一些海关请求像图形API。

For MS Teams , you can also get more information by calling GetConversationMembersAsync and call AsTeamsChannelAccount method on the members that you got (this method is included in Microsoft.Bot.Connector.Teams NuGet package) 对于MS Teams ,您还可以通过调用GetConversationMembersAsync并在获取的成员上调用AsTeamsChannelAccount方法来获取更多信息(此方法包含在Microsoft.Bot.Connector.Teams NuGet包中)。

Sample: 样品:

// Fetch the members in the current conversation
var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
var members = await connector.Conversations.GetConversationMembersAsync(context.Activity.Conversation.Id);

// Concatenate information about all the members into a string
var sb = new StringBuilder();
foreach (var member in members.Select(m => m.AsTeamsChannelAccount()))
{
    sb.AppendLine($"GivenName = '{member.Name}', Email = '{member.Email}', User Principal Name '{member.UserPrincipalName}', AAD ObjectId '{member.ObjectId}', TeamsMemberId = '{member.Id}'");
}

// Post the member info back into the conversation
await context.PostAsync($"People in this conversation: {sb.ToString()}");

With this call you will have additional interesting values: Email and ObjectId (which is the user's Azure AD object ID). 通过此调用,您将获得其他有趣的值: EmailObjectId (这是用户的Azure AD对象ID)。

As a conclusion, you still have to log your user if you need to do some authenticated logic, but in MS Teams case you have more information and ways to do it. 结论是,如果您需要执行某些经过验证的逻辑,则仍然必须登录用户,但是在MS Teams情况下,您将拥有更多信息和方法。

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

相关问题 如何使用 c# 针对 Azure AD 验证用户密码 - How to Authenticate Pasword of User against Azure AD using c# 针对Azure AD进行身份验证 - Authenticate against Azure AD 如何针对Azure Active Directory验证用户 - How to authenticate user against Azure Active Directory 如何使用身份服务器 3 和 Microsoft 团队应用程序使用 Azure AD 令牌进行身份验证 - How to authenticate using Azure AD token using identity server 3 and microsoft teams app 如何在python中针对Azure存储blob对用户进行身份验证? - How do I authenticate a user against an Azure storage blob in python? SharePointOnline:如何通过CSOM从Azure AD对用户进行身份验证 - SharePointOnline: How to authenticate user from Azure AD via CSOM 如何通过代表用户恢复令牌来对用户进行身份验证 - Azure AD - How to Authenticate a user by recovering a token on their behalf - Azure AD 如何验证 Azure AD 用户? - How to Authenticate Azure AD users? 如何在非交互式工作流程中从浏览器对 Azure AD 进行身份验证? - How can I authenticate against Azure AD from a browser in a non-interactive workflow? 带有 Azure AD 身份验证的 SaaS 应用程序作为带有 App Studio 的 MS Teams 应用程序 - SaaS Application with Azure AD authentication as MS Teams App with App Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM