question

SubratKumarSahu-2137 avatar image
0 Votes"
SubratKumarSahu-2137 asked SubratKumarSahu-2137 commented

Adding Custom attribute to Azure AD adn display the attribute in User profile

I have a requirement to add custom attributes to user profile of Azure AD B2B tenant. based on this attribute some logic need to be performed.
Also i need to add attribute data type as multivalued.

azure-ad-b2b
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ShwetaMathur avatar image
0 Votes"
ShwetaMathur answered SubratKumarSahu-2137 commented

@SubratKumarSahu-2137


You can add custom attribute for user in Azure AD B2B using Microsoft Graph API extentionProperty

While creating extension , specify targetObjects "User" to add the attribute for every user .



Pre-requisites : Application should be registered in Azure AD and has Directory.ReadWrite.All permissions to add custom property to directory objects.

1) Create Extension Property using POST request

https://graph.microsoft.com/v1.0/applications/{object-id of application}/extensionProperties

Request Body:

{
"name": "extensionName",
"dataType": "string",
"targetObjects": [
"User"
]
}


In response you will get "name": "extension_xxxx_extensionName"

Once attribute has been created, you can update value for each user using below:


2) Patch request:
https://graph.microsoft.com/v1.0/users/{user id}

{
"extension_xxxx_extensionName": "isPresent"
}

To list attribute added in user profile using:

Get request:

https://graph.microsoft.com/beta/users/{username}@{tenant-id}.onmicrosoft.com

"refreshTokensValidFromDateTime": "2021-09-25T17:28:14Z",
"showInAddressList": null,
"signInSessionsValidFromDateTime": "2021-09-25T17:28:14Z",
"state": null,
"streetAddress": null,
"surname": "bbbb",
"usageLocation": "IN",
"userPrincipalName": "shweta@xxx.onmicrosoft.com",
"externalUserState": null,
"externalUserStateChangeDateTime": null,
"userType": "Member",
"extension_xxx_extensionName": "isPresent",
"employeeOrgData": null,
"passwordProfile": null,






· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Shweta,

Thanks for your response.

I have already tried this option. but in this option we can only create attribute datatype as "String"/"Integer"/"Boolean".

But my requirement is for multivalued attribute that mean data type as "array" or similar such type.


Thanks,
Subrat

0 Votes 0 ·