I need to find a way to get the user UI languages set in SharePoint Online.
The problem is:
It seems to be impossible to load the PersonProperty for the user language using Client Object Model for users other than the current user. I tried this using a tenant sharepoint administrator user as context.credentials and using an azure ad application having all sharepoint permissions possible. Also settings the property to "public" in user profile service did not change anything.
Are there any other methods available to get the user UI language (e.g. Microsoft Graph)? It is necessary that these methods can be executed in application context.
In Server Object Modell there was the SPUser.LanguageSettings but for some unkown reasons it does not exist in CSOM.
PeopleManager.GetUserProfileProperties is by the way still undocumented since release in april.
Expected or Desired Behavior
Using the PeopleManager functions GetPropertiesFor or GetUserProfileProperties should return the language properties for the user.
Observed Behavior
The language property is always empty or null except when loading the properties for the current user.
Steps to Reproduce
Create a basic concolse application. Add the csom dlls and add a function with the following code:
ClientContext context = new ClientContext("testurl");
var user = context.Web.EnsureUser("userloginname");
context.Load(user, u => u.LoginName);
context.ExecuteQuery();
PeopleManager peopleManager = new PeopleManager(context);
PersonProperties personProperties = peopleManager.GetPropertiesFor(user.LoginName);
//Get the property for a user other than the current user
//version 1 other user
context.Load(personProperties, p => p.UserProfileProperties);
context.ExecuteQuery();
//version 2 other user
var profilePropertyValues = peopleManager.GetUserProfileProperties(user.LoginName);
context.ExecuteQuery();
Console.WriteLine(profilePropertyValues.Value["0|SPS-MUILanguages"]);
Console.WriteLine(personProperties.UserProfileProperties["SPS-MUILanguages"]);
//Get the property for the current user
user = context.Web.CurrentUser;
context.Load(user, u => u.LoginName);
context.ExecuteQuery();
//version 1 current user
personProperties = peopleManager.GetPropertiesFor(user.LoginName);
context.Load(personProperties, p => p.UserProfileProperties);
context.ExecuteQuery();
//version 2 current user
profilePropertyValues = peopleManager.GetUserProfileProperties(user.LoginName);
context.ExecuteQuery();
Console.WriteLine(profilePropertyValues.Value["0|SPS-MUILanguages"]);
Console.WriteLine(personProperties.UserProfileProperties["SPS-MUILanguages"]);