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

Subrat Kumar Sahu 1 Reputation point
2021-10-13T08:03:04.787+00:00

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.

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 27,381 Reputation points Microsoft Employee
    2021-10-22T15:23:05.473+00:00

    @Subrat Kumar Sahu

    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@X .onmicrosoft.com",
    "externalUserState": null,
    "externalUserStateChangeDateTime": null,
    "userType": "Member",
    "extension_xxx_extensionName": "isPresent",
    "employeeOrgData": null,
    "passwordProfile": null,