Open Visual Studio 2012 (Run as administrator).
Go to File=> New => Project.
Select Console Application in the Visual C# node from the installed templates.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SharePoint.Client;
- using Microsoft.SharePoint.Client.UserProfiles;
-
- namespace UserProfileService
- {
- class Program
- {
- static void Main(string[] args)
- {
-
- string siteURL = "http://gowtham/";
-
-
- ClientContext clientContext = new ClientContext(siteURL);
-
-
- PeopleManager peopleManager = new PeopleManager(clientContext);
-
-
-
- PersonProperties personProperties = peopleManager.GetMyProperties();
- clientContext.Load(personProperties, p => p.AccountName, p => p.Email, p => p.DisplayName);
- clientContext.ExecuteQuery();
-
- Console.WriteLine("Account Name: " + personProperties.AccountName);
- Console.WriteLine("Email: " + personProperties.Email);
- Console.WriteLine("Display Name: " + personProperties.DisplayName);
- Console.ReadLine();
- }
- }
- }
Hit F5. The output will be displayed in a console window.
Note: Please add a assembly reference in a visual studio solution explorer.
Add the following assemblies from hive 15 (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI).
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll