How to: Add an Azure Active Directory (AAD) custom property to the UserContext - akumina/AkuminaTraining GitHub Wiki

Applies to

Akumina 4.0.0.0 and later

This assumes you are using Office 365/SharePoint Online with Azure Active Directory (AAD)

Introduction

When using Azure Active Directory, if you have custom properties you will often want to use these for personalizationand other purposes. This article explains how to add a custom property in Azure Active Directory (AAD) to the UserContext.

User Properties-Custom

Overview

By default The Akumina framework will return a base set of properties from AAD, shown below.

  • Department
  • UsageLocation
  • DisplayName
  • GivenName
  • Id
  • JobTitle
  • Mail
  • MobilePhone
  • OfficeLocation
  • PreferredLocation
  • Surname
  • UserPrincipalName
  • BusinessPhones
  • City
  • State
  • PostalCode

Code

In our example, we want to get 2 additional properties from AAD:

  • extension_15a57b96db9b4c1db3446b618c8eeab6_employeetype
  • usagelocation

To do so, we need to add them to the call that is made to get the current user properties, by editing the Akumina.Digispace.UserContext.customProperties object.

We edit the property as we want to add fields to the call.

In our site's digitalworkplace.custom.js file (or equivalent) we add in the following:

Akumina.Digispace.UserContext.customProperties += ",extension_15a57b96db9b4c1db3446b618c8eeab6_employeetype,usagelocation";

Example

In our example, we add in the code above to retrieve the extra properties.

User Properties-Init

We now see the usagelocation property shown in the Akumina.Digispace.UserContext.userProperties.CustomProperties object:

User Properties-Custom