tags:

views:

628

answers:

1

Hi,

My company uses MS Office Communicator Server (OCS) 2007 R2, and I am accessing with C# with the SDK.

If I right click on a contact in OCS, I get the option to 'View Contact Card'. I want access to this via the API!

Unfortunately I can find nothing in the SDK documentation to get at this. There is a method called 'ViewProfile' which is unsupported, and I can find nothing out there about it.

I could of course go directly to the Active Directory account of the contact, but that would require my machine to connect to the organization via VPN. Since most of us work 'offline' I would prefer not to do this. (The data I need is anyway in OCS!)

Thanks in advance, Andrew

A: 

If you subscribe to the targeted user's presence updates, you can capture this information using the 'contactCard' presence protocol type...

// Event handler to process remote target's presence notifications
void RemotePresence_PresenceNotificationReceived(object sender, RemotePresenceNotificationEventArgs e)
{
    // Notifications contain all the notifications for one user.
    foreach (RemotePresentityNotificationData notification in e.Notifications)
    {
        // Each user will send a list of updated categories. We will choose the ones we're interested in and process them.
        foreach (PresenceCategoryWithMetaData category in notification.Categories)
        {
            if (category.Name.Equals("contactCard"))
            {
                //get the xml data
                string rawXml = category.CreateInnerDataXml();
                if (rawXml == null || rawXml.Trim().Length == 0)
                {
                    break;
                }

                StringReader reader = new StringReader(rawXml);
                XmlDocument metadataDocument = new XmlDocument();
                metadataDocument.Load(reader);
                // Traverse the xml to get the phone numbers
            }
        }
    }
}

The above code in a bit more detail and information on how to subscribe to remote user(s)' presence updates can be found here...

http://blogs.claritycon.com/blogs/michael_greenlee/archive/2009/03/10/subscribe-to-presence-in-ucma-v2-0.aspx

invenetix
Many thanks, I'll give this a go
Andrew