I am using _spPageContextInfo object to get currently logged in username in SharePoint 2013.In this process first i will get userId value and then i will make an ajax call with this userId value and i will get current user values. Its working fine. Till now i am getting userLoginName and EMail values. Now i need to find out user alias. Unfortunately the _spPageContextInfo object does contain any user alias property.So please help me in this scenario.

BTW i know that there is jQuery plugin called SPServices to find user values but even this is not much helpful to me as it also does not contain any information about user alias.

3 Answers 3


You can always scrape it from the DOM if you need to. The exact code will depend on what version of SharePoint you are running.

Open your favorite browser's developer tools, and search the DOM for your name. In this example, I'm using an Office 365 site:

enter image description here

In this case my name is in a div with the ID of SuiteNavUserName, so the code would be...


If you are using _spPageContextInfo.userId, what are you using to get your other User values?

You can make a REST call to https://{your site}/_api/GetUserById({id}) to grab the values. The alias should be a Title value?

  • Hey @z.rahui thanks for the quick answer and yes exactly i am making the same REST call you mentioned above. Are you sure that Title value is the user alias ? Commented Jul 30, 2014 at 4:21
  • If you are meaning the 'Display Name' value for the user then Yes (tested in O365). Otherwise, what are you referring to by Alias? Are you meaning a Search alias?
    – z.rahui
    Commented Jul 30, 2014 at 4:46
  • I think I need search alias not display name. Can you tell me how can I get that Search alias value? Commented Jul 30, 2014 at 5:03
  • If you are meaning a search alias, then all that really refers to is a Managed Property in Search linked to a User Profile property. Find out what property is set as an Alias and find it using the REST API for User Profiles: {web}/_api/SP.UserProfiles.PeopleManager/GetMyProperties
    – z.rahui
    Commented Jul 30, 2014 at 5:21

Sample Code Snippet as below

        userid = _spPageContextInfo.userId; // Fetches the UserID of the Current Logged in User

    //Endpoint is /_api/web/getuserbyid('userid')
    var url = String.format("{0}/_api/web/getuserbyid('{1}')",siteURL,userid);

        url : url,
        contentType : "application/json;odata=verbose",
        headers : { "accept" : "application/json;odata=verbose" },
        success : function(data){
            $('#txtUserTitle').val(data.d.Title); //Fetches the User Name
            $('#txtUserLogin').val(data.d.LoginName); // Fetches the Login Name as "i:0#.w|abc\def"
            $('#txtUserEmail').val(data.d.Email); //Fetches the Email ID
            $('#txtUserIsSiteAdmin').val(data.d.IsSiteAdmin); //Fetches info about whether the user is Site Admin
        error : onerror

The endpoint gives Title, LoginName, Email, IsSiteAdmin(Boolean) and few other as return type. For Corresponding UserName we can get by data.d.Title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.