Introduction

People Search and User Profiles are amongst the popular topics that everyone use in their projects every now and then. With SharePoint 2013, a lot of functionality has been included in the Client API's by Microsoft. If you consider user profiles itself, in SharePoint 2010 you cannot fetch user profiles using client side object model. However, with SharePoint 2013, you have a wide variety of methods that you can use to fetch the user profile information using client object model. The search API is also expanded greatly.

Scenario

We can make use of search and user profile API so that based upon the search query we can fetch all users using the people search API and then retrieve their profile information using user profile API. All this will be implemented purely using client object model. 

Its important to mention here that using user profile client API, we cannot retrieve all user profiles. For such a scenario, recommended approach is first make use of people search API to fetch user profiles and once you have all users, simply make use of user profile API to fetch the profile information.

 

Prerequisites

For search you need to have the following prerequisites based upon the approach you are using.
  1. Microsoft.SharePoint.Client.Search.dll If you are making use of .NET client object model you need to add reference to this dll.

  2. SP.Search.js - If you are using JSOM, you need to ensure that this js file is loaded on the page.

  3. http://<siteUri>/_api/search/- If you are making a REST call then you need to use this access point.

For user profiles you need to have the following prerequisites based upon the approach you are using.

  1. Microsoft.SharePoint.Client.UserProfiles.dll - If you are making use of .NET client object model you need to add reference to this dll.

  2. SP.UserProfiles.js - If you are using JSOM, you need to ensure that this js file is loaded on the page.

  3. http://<siteUri>/_api/SP.UserProfiles.PeopleManager - If you are making a REST call then you need to use this access point.

 

In order to have a detailed understanding of the code have a look at the below article where I have  given a detailed explanation.

http://social.technet.microsoft.com/wiki/contents/articles/25074.sharepoint-online-working-with-people-search-and-user-profiles.aspx


Cheers,

Geetanjali