Hi @Anonymous · Thank you for reaching out.
You need to first extend Azure AD schema of the B2C tenant with extension_companyName attribute using b2c-extensions-app. The document you are referring to, is with example of City attribute, which is by default present in Azure AD Schema.
Please follow below steps to extend the Azure AD Schema of your B2C tenant with companyName attribute:
- Navigate to Azure Portal > Azure Active Directory > App Registration.
- Locate the b2c-extensions-app and copy the Object ID of the b2c-extensions-app.
- Open Graph Explorer by using https://developer.microsoft.com/en-us/graph/graph-explorer# url.
- Click on Sign in with Microsoft on the left and Sign in with Global Admin account who is a member of same directory and not added as external (guest) user.
- Click on Modify permissions > select Directory.AccessAsUser.All > click Modify Permissions.
- Click on Accept at consent page.
- In Graph Explorer, use following query. Where the < Tenant Name > is your_tenant.onmicrosoft.com in your case and < ObjectID of the application > is the value copied in Step 2.
POST https://graph.microsoft.com/beta/< Tenant Name >/applications/< ObjectID of the application >/extensionProperties - Use following text in the Request body. Since the targetObject is user, the attribute will be created for all Users in the tenant. Note: Please type the request body manually as with copy-paste Graph Explorer will not recognize some of the characters.
{
“name”: “companyName”,
“dataType”: “String”,
“targetObjects”: [“User”]
}
Optionally, to verify if the attribute is created in the directory and a value can be populated in the attribute, follow below steps. These steps are not needed in your case as the attribute value will be populated
- To update the attribute with a value use following query:
PATCH https://graph.microsoft.com/beta/users/your_globaladmin@your_tenant.onmicrosoft.com
And use following Request Body:
{
"extension_e175b1fc21b144019cadxxxxxxxxxxxx_companyName":"Value_to_be_assigned"
} - To verify if the attribute is updated successfully run following query:
GET https://graph.microsoft.com/beta/users/ < User’s UPN or Object ID >
-----------------------------------------------------------------------------------------------------------
Please "Accept the answer" if the information provided helped you. This will help us and others in the community as well.