How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM


Create a console application in Visual Studio 2013


Import the following namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;

using System.Net;
using System.Security;
using System.Globalization;


Add references to the following .dll


 static void Main(string[] args)

        public static void ReadUserProfile()
            Uri oUri = new Uri("");

            Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, "", "password");
            using (ClientContext oClientContext = new ClientContext(oUri))
                            oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
                PeopleManager oPeopleManager = new PeopleManager(oClientContext);
                PersonProperties oPersonProperties = oPeopleManager.GetPropertiesFor("i:0#.f|membership|");
                oClientContext.Load(oPersonProperties, p => p.AccountName, p => p.UserProfileProperties);

                foreach (var oProperty in oPersonProperties.UserProfileProperties)
                    Console.WriteLine(string.Format("{0}: {1}",
                        oProperty.Key.ToString(), oProperty.Value.ToString()));


CSOM userprofile

The account parameter to be passed for the method oPeopleManager.GetPropertiesFor is not straight-forward. For office 365 SharePoint accounts, the parameter has to be passed in this format "i:0#.f|membership|". Replace the youruserid accordingly.

The complete source code for this article is available in this location

 Subscribe to my blog

One thought on “How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM

  1. Pingback: How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM - My experiments with SharePoint, Azure and .NET using Visual Studio

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.