Version

User.getProfileByName

Method used to search the user profiles from a web’s URL, returning the available information for a specific user profile.

Syntax

SPlus.User.getProfileByName (accountName, url, function (userProfileProperties){
        //Loop the Array of user profile properties
        for (var i=0; i < userProfileProperties.length; i++) {
            //Getting a JSON object with one of the properties
            var property = userProfileProperties [i];
            //Getting the name of the current property
            var name = property ['name'];
            //Getting the displayValues Array of the current property
            var displayValues = property ['displayValues'];
            //Loop the Array of displayValues of the current property
            for (var j=0; j < displayValues.length; j++) {
                    //TODO: Handle the Array of displayValues
            }
            //TODO: Implement what to do with each user profile property
            }
}, function (errorResponse){
        var error = errorResponse['error#displayValue']; //Getting the error
        //TODO: Implement how to handle errors
});

User.getProfileByName Parameters

Parameter

Type

Description

accountName

String

User account name to search for.

url

String

URL to the SharePoint site.

onSuccess callback function

Parameter

Description

function (userProfileProperties)

Success callback function to be implemented, which received an Array with user profile properties (JavaScript Objects that contain three properties).

onError callback function

Parameter

Description

function (eResponse)

Error callback function to be implemented, which receives the eResponse JavaScript Object.

For further details about user profile properties, see the Plan user profiles article.

Active Directory SharePoint Authentication

When your SharePoint authentication is configured through Active Directory, the user account name parameter sometimes needs to be passed in a claims-encoded format.

Examples:

Username

Encoded Parameter

johnSmith (windows-based)

i:0#.w|mydomain\\johnSmith

jSmith@acompany.onmicrosoft.com (office 365)

i:0#.f|provider|jSmith@acompany.onmicrosoft.com

For further information, refer to SharePoint 2013: Claims Encoding article.