2

I'm having a hard time to accomplish the below.

I have small app empowering the users to query user profile properties (SharePoint Online). I'm using CSOM which is quite straight forward.

I can pull the user's profile properties. But CSOM only returns the properties Key/Value pairs. The key is the Internal Name and not the Display name (External User) that user usually see from the UI.

The users of this app can query the profile property by the External name, i.e. they can key in "First Name" instead of "FirstName" or "Job Title" instead of "SPS-JobTitle".

As workaround, I have made soap request to /_vti_bin/UserProfileService.asmx which it returns all the user properties (Display Name, Internal Name) and from there I have some line of codes to match Internal name with its display name.

Unfortunately, I'm using OAuth2.0 authentication (Azure AD app) which /_vti_bin/UserProfileService.asmx does not support but CSOM supports.

Please guide me how can I user's profile property External names (Display name) with its value?

I hope my question clear enough.

2 Answers 2

0

You can use Rest API to query for the users' display name.

$.ajax({
  url: "http://<site url/_api/sp.userprofiles.profileloader.getprofileloader
    /getuserprofile",
  type: "POST",
  headers: {
    "X-RequestDigest": <form digest value>,
    "accept": "application/json;odata=verbose"
  },
  success: successHandler,
  error: errorHandler
});

Here Account Name and Display Name should server your purpose. The above is a javascript code, which you can easily embed. However, if you want, you can also look into how to use share point rest in C# managed code

Please refer to Restful Endpoints for Userprofile services

2
  • Thanks Swayam for your reply. That method is what CSOM (.NET) is doing. If you notice it will return key value pairs. The Key here is the property's key. I guess i have created confusion when i said Display name. I don't mean the user's Display name but the property's display name. For example, property FirstName is the property key. I want the property display name as well which is First Name (Friendly display name with white spaces)
    – HakTech
    Jul 15, 2017 at 12:41
  • UserProfileProperties Collection( SP.KeyValue ) The user profile properties for the user. I dont want only the Key Value but also the property's display name that users usually see in the sharepoint portal UI
    – HakTech
    Jul 15, 2017 at 12:55
0

In case anyone comes cross this. The workaround that i followed to accomplish that is retrieving all the fields of sharepoint online list named "User Information List": https:///_api/Lists/getbytitle('User Information List')/fields

Your Answer

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

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