function GetUserProperties(clientContext, peopleManager, targetUser, profilePropertyNames){
var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(
clientContext,
targetUser,
profilePropertyNames);
var userProfileProps = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
clientContext.load(userProfilePropertiesForUser);
clientContext.executeQueryAsync(
function () { console.log(userProfileProps[0] + " works in " + userProfileProps[1] + " as a " + userProfileProps[2]); },
function () { console.log("Failure") });
}
function GetAllUserProperties(){
var targetUser = "domainname\\username";
// Create the client context and get the PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
// Get user profile properties for the target user.
// Specify the properties to retrieve and create the UserProfilePropertiesForUser object.
// Then get the requested properties by using the getUserProfilePropertiesFor method.
var profilePropertyNames = ["PreferredName", "Department", "Title"];
var users=["domainname\\Username", "domainname\\Username", "domainname\\Username"];
for(var i=0; i<users.length;i++){
GetUserProperties(clientContext, peopleManager, users[i], profilePropertyNames);
}
}