I am using Azure AD application with Azure B2c. As per the official Microsoft document, we can get additional claims using Azure AD policy. https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-claims-mapping
I managed to get JobTitle using this approach, however, the department and mobilePhone fields are always empty. Below is the PowerShell script that I use to create AD claim mapping policy.
$claimsMappingPolicy = [ordered]@{
"ClaimsMappingPolicy" = [ordered]@{
"Version" = 1
"IncludeBasicClaimSet" = $true
"ClaimsSchema" = @(
[ordered]@{
"Source" = "user"
"ID" = "JobTitle"
"JwtClaimType" = "JobTitle"
},
[ordered]@{
"Source" = "user"
"ID" = "Department"
"JwtClaimType" = "Department"
},
[ordered]@{
"Source" = "user"
"ID" = "MobilePhone"
"JwtClaimType" = "MobilePhone"
}
)
}
}
$appID = "Azure AD App ID"
$policyName = "ClaimsMappingPolicy"
$sp = Get-AzureADServicePrincipal -Filter "servicePrincipalNames/any(n: n eq '$appID')"
$existingPolicies = Get-AzureADServicePrincipalPolicy -Id $sp.ObjectId `
| Where-Object { $_.Type -eq "ClaimsMappingPolicy" }
if ($existingPolicies) {
$existingPolicies | Remove-AzureADPolicy
}
$policyDefinition = $claimsMappingPolicy | ConvertTo-Json -Depth 99 -Compress
$policy = New-AzureADPolicy -Type "ClaimsMappingPolicy" -DisplayName $policyName -Definition $policyDefinition
Add-AzureADServicePrincipalPolicy -Id $sp.ObjectId -RefObjectId $policy.Id
Write-Output ("New claims mapping policy '{0}' set for app '{1}'." -f $policy.DisplayName, $sp.DisplayName)