Display Custom Attribute of an Azure AD User in Employee Directory
Extension attributes in the on-premise active directory (AD) allow extending directory objects with new attributes. These attributes may be synchronized with Azure AD. Once the attributes are synced, you may display them on the SharePoint site and Microsoft Teams with the Employee Directory web part.
This article describes how to set up the Employee Directory web part to display custom attributes of user object from Azure AD.
Custom attributes are not named like they are in the on-premises AD, for example, fax. Instead, the custom attribute' name in Azure AD is like below:
Therefore to use custom attributes, you need to retrieve their names from Azure AD.
Additional PowerShell modules are required to interact with the Microsoft 365 environment.
Open PowerShell and run the following cmdlets to install
Install-Module -Name MSOnline
Install-Module -Name AzureAD
Connect to your environment
Run the Connect-AzureAD cmdlet to connect to your Microsoft 365 environment.
And sign in with your corporate account.
Getting Custom Attributes
email@example.com with the user login in your Azure AD, which has the necessary attributes, and run the script below.
$userLogin = "firstname.lastname@example.org"
Get-AzureADUser -ObjectId $userLogin | Select -ExpandProperty ExtensionProperty
The result listed extension properties that may be used as custom attributes in the Employee Directory web part.
Web Part Properties
Open the page where the Employee Directory web part is placed in edit mode and go to web part settings, and select Configure under Custom Columns heading:
Add custom attributes to the list and click Save button.
Both Employee Directory and Employee Directory (Azure AD) have similar settings according to custom user properties.
Once custom attributes are defined, marked as visible of them shows up on the employee details pane:
Publish the page to save changes.