Display User Picture in Lync 2013

╄→гoц情女王★ 提交于 2019-12-11 09:29:07

问题


I am working on small application using the lync 2013 sdk. Is there any way provided in sdk where I can implement a functionality to allow user to upload his picture using any API provided in the SDK.

If it is possible then what and where is the best way to store it, if the users are configured in the active directory?

Waiting for a positive response from your side.

Regards

Amit


回答1:


You can get a stream to the photo via the SDK using

var photoStream = Client.Self.Contact.GetContactInformation(ContactInformationType.Photo) as System.IO.Stream

And whilst you can read the stream you can't write to it as you are at this point looking at contact information from AD.

Kind of feels like you want to write something to change the photo in the photoThumbnails attribute of AD not in Lync.




回答2:


Update as of 12/11/2013

The latest Lync update (Lync Client CU3 (November Update)) has the option to set a photo added back to the GUI.

  • Link to the KB Article
  • Link to the Download

Article with explanations and screenshots can be found here: Lync Client CU3 (November Update) – Show a picture from a website!.


Original Answer

Though this is a different problem, my answer to this question (Displaying a photo for an Application endpoint) is valid here as well:

Basicly, there is an option to set a user's photo to an URL, but it is no longer displayed in the Lync 2013 client interface (it was there in the Lync 2010 client). If you can get your code to publish the image to a web-accessible location, you could publish the URL to it and change your user picture that way.

For reference, the answer to the other question:


Publishing presence information (which includes photo settings) is done on the LocalEndpoint.LocalOwnerPresence. Both UserEndpoint and ApplicationEndpoint derive from LocalEndpoint, so this should be doable really.

The actual publishing gets slightly complex because there are a lot of different combinations of 'levels' to publish on:

First, there are a bunch of InstanceID values that you need to know about, read up on them here: Presence data source and category instance ID

Second, there is a value for who this presence applies to, see Microsoft.Rtc.Collaboration.Presence.PresenceRelationshipLevel. Don't publish on Unknown, you'll get an exception.

public enum PresenceRelationshipLevel  
{  
    Unknown = -1,  
    Everyone = 0,  
    External = 100,  
    Colleagues = 200,  
    Workgroup = 300,  
    Personal = 400,  
    Blocked = 32000,  
}

You need to publish a PresenceCategoryWithMetaData for the user photo properties, which is part of container 0x5, "Presentity information".

var photoPresence = new PresenceCategoryWithMetaData(
    0x5, // The container id
    (int)PresenceRelationshipLevel.Everyone,
    new ContactCard(0x5) // Same container ID again
    {
        IsAllowedToShowPhoto = true,
        PhotoUri = "<uri to your photo here"
    });

You can set an ExpiryPolicy on this object too, should be self explainatory really. Then publish this presence object on your endpoint:

Endpoint.LocalOwnerPresence.BeginPublishPresence(new[] { photoPresence  }, cb => { 
    Endpoint.LocalOwnerPresence.EndPublishPresence(cb);
}, null);

And that should do it, really. I ended up explicitly publishing to all relationship levels because it didn't cascade the data as logically expected.



来源:https://stackoverflow.com/questions/19404440/display-user-picture-in-lync-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!