SharePoint 2013: Access User Profile Service Data using JSOM in SharePoint 2013
User Profile – It has all the information of people in an organization in an organized manner. It displays all properties like AccountName, FirstName, LastName, WorkEmail etc. related to a user.
User Profile Service Application – It is considered as centralized location to store all user profiles and also allows the administrators to configure or manage profiles, profile synchronization, My Site, Social Tags etc. It can also pull information from Directory Services like Active Directory.
My Site – A personalized site for individual user to manage their information and store documents, links etc. It provides rich networking and social features by enabling users to share information about themselves or their activities. My Site is accessible by clicking on User Name on top right corner of SharePoint page.
Manage and Access User Profile Data
Since we are going to work using JSOM, we can perform only 'Read ' operations with an exception that Profile picture can be changed using JSOM (or CSOM or REST)
*Server Side Code allows Read/Write both operations.
Retrieve User Profile Properties using JSOM
Lets create a SharePoint Hosted App and retrieve user information in that app –
Launch Visual Studio 2013 and select "App for SharePoint 2013" from New Project. After selecting above project type, you are presented with a window to connect to SharePoint site and select type of app to be deployed (see below screenshot) Here I have provided mu SharePoint Online developer site URL and selected SharePoint Hosted App. Click Finish.
3.) After the project is created, you will see a set of folders/filers added in Solution Explorer added by default to the project.
Here we need to add one more library to start working with User Profiles