Custom attribute in the Azure Active Directory
Problem statement
We are managing the data of BirthDate, HireDate and other custom
attribute for Users in the SharePoint User Profile and checked the data added
to User Profile are not available in the Azure Active Directory user’s profile.
Also, we are using Azure AD for managing all other information of users.
So, is there any way to get that data to Azure AD or manage that fields
in the Azure AD?
If we want to manage data for fields like BirthDate,
HireDate or Hobbies etc. which are not available as inbuild properties in the
Azure Active Directory then what will be the approach. Also, we must use only
Azure AD to manage the user information and do not want to use the user profile
to manage the information of users.
Solution
The data from the SharePoint User Profile is not synced with the Azure
Active Directory. So, you will not get the BirthDate, HireDate and other custom
attributes in the Azure AD.
To manage the extra fields BirthDate,
HireDate and other custom attributes in Azure AD, we need to create the custom
attribute. And to add and get data from the attribute you must use the Graph
API query and Graph Explorer to test the query. Here, we have also provided the
approach to get data in SPFx SharePoint webpart and in .NET framework using
CSOM.
To manage the extra fields in Azure AD which are not
available in AD, we need to create the custom attribute. And to add and get
data from the attribute you must use the Graph API query and Graph Explorer to
test the query. Here, we have also provided the approach to get data in SPFx
SharePoint webpart and in .NET framework using CSOM.
Follow the below steps for the solution to the above problem statement.
Create the custom attribute in the Azure AD
Step 1: Open the portal.azure.com in the new tab
Step 2: Click on the
External Identities and then Custom User Attribute to create the new custom
attribute in the Azure AD.
Step 3: Click on the
Add button.
Step 4: Fill in the
name of the attribute and select the data type and then click on create.
NOTE: You can get the details using Graph Explorer.
Follow the below steps to add and update the data to
the created custom attribute.
Step 1: Open the
graph explorer with the link below to add the data for the users.
https://developer.microsoft.com/en-us/graph/graph-explorer
Step 2: GET query to
check the user data
NOTE: For the created extension attribute name
extension_605f513ba52e43a08961a1c90a28d36a_Birthday
Birthday = Name of the created
attribute
605f513ba52e43a08961a1c90a28d36a = Id of the azure AD app get from the ‘App Registrations’
Step 3: PATCH query to add the data to the created custom attribute
https://graph.microsoft.com/v1.0/users/userPrincipalNameOfUser
Step 4: GET query to
check the user data updated.
To get the data of custom attributes for users in the
SPFx webpart with React js
To get the details of users in
the custom webpart, we need to use the MSGraphClient with the code below.
To get the data of custom attribute for users in the .NET framework using CSOM
Add the select query to the AD
function call and while getting data use below:
Comments
Post a Comment