UCMA 4.0如何从PresenceNotificationRecived处理程序获取用户名

本文关键字:程序 处理 获取 用户 PresenceNotificationRecived UCMA | 更新日期: 2023-09-27 18:29:09

我正在使用UCMA 4.0来获取用户的状态。我定义了一个类似的事件处理程序

    _remotePresenceView.PresenceNotificationReceived += new EventHandler<
        RemotePresentitiesNotificationEventArgs>(RemotePresence_PresenceNotificationReceived);

其实现如下:

// Event handler to process remote target's presence notifications
private void RemotePresence_PresenceNotificationReceived(object sender,
    RemotePresentitiesNotificationEventArgs e)
{
    Console.WriteLine(String.Format("Presence notifications received for target {0}", <<How do I get the username here>>
        ));
    // Notifications contain all the notifications for one user.
    foreach (RemotePresentityNotification notification in e.Notifications)
    {
        if (notification.AggregatedPresenceState != null)
        {
            Console.WriteLine("Aggregate State = "
                + notification.AggregatedPresenceState.Availability);
        }
    }
    Console.WriteLine("Press ENTER to delete the contact, delete the group, and unsubscribe to the "
        + "presence of the remote user.");
}

我的问题是,我如何获得事件处理程序代码中出现更改的人员的用户名?

UCMA 4.0如何从PresenceNotificationRecived处理程序获取用户名

RemotePresentityNotification类上有一个ContactCard属性,它将提供包括DisplayName在内的各种详细信息,因此在您的情况下,您需要引用notification.ContactCard.DisplayName

您还可以使用DirectorySearcher执行Active Directory查找,方法是使用通知的PresentityUri属性交叉引用用户的AD"msRTCSIP PrimaryUserAddress"属性。