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.
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.