Teams Client的COM对象-Microsoft.Office.Uc

时间:2019-07-03 08:13:43

标签: com microsoft-teams skype-for-business

我正在尝试访问Microsoft Teams客户端 COM对象
在PowerShell中使用Skype for Business和Lync客户端对象是可能的。

this完全相反。

[Reflection.Assembly]::LoadFile("C:\temp\Microsoft.Lync.Model.dll")
[Reflection.Assembly]::LoadFile("C:\temp\microsoft.office.uc.dll")
$lyncclient = [Microsoft.Lync.Model.LyncClient]::GetClient()
$lyncclient2 = [Microsoft.Lync.Model.ContactInformationType]::Availability
$lyncclient.Self.Contact.GetContactInformation($lyncclient2);

此代码将导致当前的Lync / Skype用户存在。

$teamsClient = [Microsoft.Office.Uc.IUCOfficeIntegration]
$teamsClient.GetInterfaces()

以下小文章https://www.msxfaq.de/teams/api/teams_presence.htm 我什至无法在Get-ChildItem HKLM中接收Com obj列表 仅在Get-ChildItem HKCU中。

我的目标是使用与Outlook相同的功能,以读取MS Teams中用户的状态。

2 个答案:

答案 0 :(得分:0)

团队根本不使用COM,也永远不会使用COM。

我们计划支持Microsoft Graph中的状态API没有共享日期。

答案 1 :(得分:0)

Teams 仍在通过 COM 公开一些功能。它实现了 IUCOfficeIntegration 接口,因此 Microsoft Outlook 可以在 Outlook 本身中显示联系人的 Teams 可用性状态。

可以在此处找到有关 Office 集成如何工作的更多信息。

https://github.com/MicrosoftDocs/office-developer-client-docs/blob/master/docs/shared/integrating-im-applications-with-office.md

我只是快速描述了我为通过 COM 接收可用性信息所做的工作。 请注意,这是 C# 代码。我希望它仍然有帮助。

获取 Teams COM 类的 ClassID

安装 Outlook 和 Teams 后,Teams 会将自身注册为能够向 Outlook 提供可用性信息的 IM 应用程序。这是通过编写一些注册表节点来完成的。 ClassID 可以在这里找到 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\IM Providers\Teams

获取可用性:

为此,我基本上颠倒了链接文章中展示如何实现 Office 集成客户端的所有步骤,因为我想使用 Teams 客户端。 请注意,需要安装 Lync SDK (https://www.microsoft.com/en-us/download/details.aspx?id=36824),因为所有 Office 集成接口都在其中定义。 (需要参考 Microsoft.Office.Uc.dll)。也许这个库可以

class Program
{

  static void Main()
  {
    var version = "15.0.0.0";
    var teams = (IUCOfficeIntegration) new TeamsOfficeIntegration();

    var client = (IClient) teams.GetInterface(version, OIInterface.oiInterfaceILyncClient);

    var contactManager = client.ContactManager;

    var uri = "name@company.com";
    var contact = contactManager.GetContactByUri(uri);
    var availibility =
        (ContactAvailability) contact.GetContactInformation(ContactInformationType.ucPresenceAvailability);
  }

  [ComImport, Guid("00425F68-FFC1-445F-8EDF-EF78B84BA1C7")]
  public class TeamsOfficeIntegration
  {
  }
}

我会尝试上传一个小项目到GitHub来演示......

由于 Powershell 基于 .NET,这也应该是可能的。或者可以编写一个小的 C# 互操作库。