Zum Inhalt springen

Azure B2C Edit User Extensions

Azure B2C Tentans are used to manage external customer identities.
https://docs.microsoft.com/de-de/azure/active-directory-b2c/

Your Azure Active Directory (Azure AD) B2C directory user profile comes with a built-in set of attributes, such as given name, surname, city, postal code, and phone number. You can extend the user profile with your own application data without requiring an external data store.
https://docs.microsoft.com/en-us/azure/active-directory-b2c/user-profile-attributes

We store there e.g. whether the user has accepted the data protection clause, and the version of the data protection clause, so that we can ask for the user’s consent in case of changes to the data protection clause.

If you need to change these extended attributes, you can do so via grapg-api from the application, or via powershell.
As we have several B2C tenants in use (DEV / Test / Prod) I wrote a small powershell script to read and change the extention value.

 # Script can be used to change azure B2C Attributs.
# you only have to change the values for the B2C Tentants to your values -> $envarray
# G.Jeuken 
# V1 29.03.2020

# customize your B2C tentants here
$envarray = @("YourB2CDev.onmicrosoft.com","YourB2CTest.onmicrosoft.com","YourProdB2C.onmicrosoft.com")
$environment = $envarray | Out-GridView -Title "Select Environment" -PassThru
if (!$environment) {exit} # stop hier if canceld or value is NULL
# we need this for the input-boxes 
Add-Type -AssemblyName Microsoft.VisualBasic


# check if connected / connect
if(!$azureConnection.Account){
    $azureConnection = Connect-AzureAD 
}

# connect to selected AzureB2C /ask for login if needed
connect-AzureAD -TenantId $environment -AccountId $azureConnection.Account  >$null 2>&1

# ask for users forename
$forename= [Microsoft.VisualBasic.Interaction]::InputBox('Enter the beginning of the users forename', 'Search for B2C User')
if (!$forename) {exit} # stop hier if canceld or value is NULL

# search for the user and show existing extentions

# build query to find user
$filter="startswith(GivenName,'"+$forename+"')"
#get user
$user = Get-AzureADUser -Filter $filter | Out-GridView -Title "Select User" -PassThru 
if (!$user) {exit} # stop hier if canceld or value is NULL
#get and show all extentions
$extentions = $user | Get-AzureADUser  | Get-AzureADUserExtension  | Out-GridView -Title "Select Extention to change" -PassThru
if (!$extentions) {exit} # stop hier if canceld or value is NULL

#ask for new Value
$textforinfobox= "New value for " + $extentions.name +   " old Value " + $extentions.Value
$newValue= [Microsoft.VisualBasic.Interaction]::InputBox($textforinfobox, 'input new value')
if (!$newValue) {exit} # stop hier if canceld or value is NULL

#set new value
Set-AzureADUserExtension -ObjectId $user.ObjectId -ExtensionName $extentions.Name -ExtensionValue $newvalue
$extentionNew=$user | Get-AzureADUser  | Get-AzureADUserExtension 
Clear-Host
Write-Host "User: " $user.DisplayName " Extention: " $extentions.Name " old Value: " $extentions.Value "changed to " 
$extentionNew  |Format-Table
Schlagwörter:

Schreibe einen Kommentar