Retrieve User Profile Properties using Client Object Model in SharePoint 2013

I’ve found an interesting link about how to retrieve some properties of user profiles in SharePoint 2013 by using its client object model, like this:

const string serverUrl = "http://serverName/";
const string targetUser = "domainName\userName";
ClientContext clientContext = new ClientContext(serverUrl);
PeopleManager peopleManager = new PeopleManager(clientContext);
string[] profilePropertyNames = new string[] { "PreferredName", "Department", "Title" };
UserProfilePropertiesForUser profilePropertiesForUser =
     new UserProfilePropertiesForUser(clientContext, targetUser,
     profilePropertyNames);
IEnumerable<string> profilePropertyValues =
     peopleManager.GetUserProfilePropertiesFor(profilePropertiesForUser);
clientContext.Load(profilePropertiesForUser);
clientContext.ExecuteQuery();
foreach (var value in profilePropertyValues)
{
     Console.Write(value + "n");
}
Console.ReadKey(false);

You can find more information in:
http://msdn.microsoft.com/es-es/library/jj163182(v=office.15).aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.