public static void GettingSomeUserProfileProperties() { const string serverUrl = "http://svg-ronald"; const string targetUser = "******"; // Connect to the client context. ClientContext clientContext = new ClientContext(serverUrl); // Get the PeopleManager object. Microsoft.SharePoint.Client.UserProfiles.PeopleManager peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext); // Retrieve specific properties by using the GetUserProfilePropertiesFor method. // The returned collection contains only property values. string[] profilePropertyNames = new string[] { "PreferredName", "DisplayName23", "Department", "Title", "AboutMe" }; Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser profilePropertiesForUser = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser( clientContext, targetUser, profilePropertyNames); IEnumerable <string> profilePropertyValues = peopleManager.GetUserProfilePropertiesFor(profilePropertiesForUser); // Load the request and run it on the server. clientContext.Load(profilePropertiesForUser); clientContext.ExecuteQuery(); // Iterate through the property values. foreach (var value in profilePropertyValues) { Console.Write(value + "\n"); } Console.ReadKey(false); }
public static void GettingSomeUserProfileProperties() { const string serverUrl = "http://svg-ronald"; const string targetUser = "******"; // Connect to the client context. ClientContext clientContext = new ClientContext(serverUrl); // Get the PeopleManager object. Microsoft.SharePoint.Client.UserProfiles.PeopleManager peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext); // Retrieve specific properties by using the GetUserProfilePropertiesFor method. // The returned collection contains only property values. string[] profilePropertyNames = new string[] { "PreferredName", "DisplayName23", "Department", "Title", "AboutMe" }; Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser profilePropertiesForUser = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser( clientContext, targetUser, profilePropertyNames); IEnumerable<string> profilePropertyValues = peopleManager.GetUserProfilePropertiesFor(profilePropertiesForUser); // Load the request and run it on the server. clientContext.Load(profilePropertiesForUser); clientContext.ExecuteQuery(); // Iterate through the property values. foreach (var value in profilePropertyValues) { Console.Write(value + "\n"); } Console.ReadKey(false); }