Office 365 SharePoint Online User Profile Custom Attribute Mapping with Azure AD attribute

Creating a custom user profile attribute in SharePoint 2013/2010 is a very common requirement. User Profile Service in SharePoint 2013/2010 allows creating profile attributes and maps with AD attributes.

After making the mapping we have to start the sync and on successful sync, the value will be updated against the profile attribute from AD. Pretty simple process and I am not going to cover the step by step process “Hot to do it in SP 2010/2013”.

We will discuss “How to DO User Profile custom attribute mapping in Office 365”.

In this article, I will explain the mapping of Employee ID Azure AD attribute to sync with Office 365 User profile attribute.

Office 365 User Profile Service doesn’t provide an option to directly do the mapping of User profile property with AD attribute.

Approach-1: CSOM User Profile property update

  • Get all the employee ID against each employee name from Azure AD in CSV format.
  • Create a User profile property as “Employee ID” in SharePoint Online user profile service.
  • Create custom CSOM script to read all data from the CSV files and update Employee ID user profile property.
  • Create a job scheduler to run the script. We need a server where we can host the script and run periodically.

Approach-2: Azure AD to User Profile Sync Tool

We have used the GitHub solution which provides below functionality and extended with below snippet code.

  • We can configure which properties to read and where to write them.
  • Authenticates & pulls data from Azure AD.
  • Authenticates and updates all user profiles with the data from Azure AD. v1 of this sample uses the SharePointOnlineCredentials object.
  • Create Azure Web Job (custom solution) which will be scheduled periodically.
  • Using Graph API you will be able to find the attribute ID. We have to
var extendedProperties = user.GetExtendedProperties().ToArray();
if (user.GetExtendedProperties().Count >= 3)
if(extendedProperties[3].Key.ToString() == “extension_0176790aabb782bda4dd4b51e9ca28c3_EmpID”){
value = extendedProperties[3].Value.ToString();
if (prop.IsMulti)

peopleManager.SetMultiValuedProfileProperty(UserProfilePrefix + user.UserPrincipalName,
prop.UserProfileAttributeName, new List<string>() { });
Console.WriteLine(“Inside the else loop of prop.IsMulti”);
peopleManager.SetSingleValueProfileProperty(UserProfilePrefix + user.UserPrincipalName,
value == null ? string.Empty : value.ToString());


Console.WriteLine(“Updated User: {0} Property: {1} New Value: {2}”,
user.DisplayName, prop.UserProfileAttributeName, value);

You may like following SharePoint tutorials:

This SharePoint tutorial learned, how to create custom attribute mapping with Azure AD attribute using CSOM and Azure AD to user profile sync tool.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)


Sambita Rath

I have 9 years of exprience into SharePoint implementation, architecture, Administrator, development and Training.Designing Information Architecture in SharePoint 2007, 2010,2013 and Office 365.