Microsoft Entra ID
Provisioning

Use directory extensions when provisioning to Active Directory

In brief

The article now explains using directory extensions to filter groups for provisioning and to map attribute values to Active Directory users. It adds separate Groups and Users examples, prerequisites, and related guidance.

What Entra admins need to know

Administrators can use the updated examples to configure provisioning scenarios such as filtering with `WritebackEnabled` or mapping `EmployeeCode` to an Active Directory attribute.

This editorial summary was generated by AI from the documentation changes. Verify important details in the full Microsoft Learn article.

Documentation change

The comparison below shows only the changed extract. Use the full-page view for complete context.

Scenario - UsingUse directory extensions with groupwhen provisioning to Active Directory

Scenario: You have hundreds of groups inA directory extension adds an attribute to the Microsoft Entra ID. You want toschema that Microsoft Entra ID owns. When you provision some of these groups but not all backfrom Microsoft Entra ID to Active Directory. You would likeDirectory, you can put that attribute to two uses: decide which objects are provisioned, or carry a quick filter that can be appliedvalue into an Active Directory attribute. Both uses work for users and for groups.

This article walks through one example of each. Select the Groups or Users tab in each step to follow the example you want. Your selection carries through the rest of the article.

TabExampleUse
GroupsWritebackEnabledProvision only the groups without havingwhose extension value is true.
UsersEmployeeCodeWrite the extension value into an Active Directory user attribute.

For background on directory extensions, see Directory extensions for provisioning Microsoft Entra ID to Active Directory. For the general mapping interface and expression syntax, see Configure provisioning to Active Directory.

Groups support attribute mapping as well. For a group whose Source of Authority is converted to Microsoft Entra ID, the GroupDN extension preserves the original organizational unit and common name. To create that extension, see Preserve a group's organizational unit and name. For the expression that reads it, see Preserve a group's original organizational unit.

AssumptionsBefore you begin

Both examples need the same starting point:

  • This scenario assumes that you already have aA working environment that is synchronizingsynchronizes users to Microsoft Entra ID.
  • We have 4 users that are synchronized.A healthy provisioning agent connected to the target Active Directory domain.
  • A Microsoft Entra ID to Active Directory configuration, or permission to create one.

Each example then needs its own objects.

Groups

This example uses the following environment:

  • Four synchronized users: Britta Simon, Lola Jacobson, Anna Ringdahl, and John Smith.
  • Three organizational Units have been createdunits in Active Directory -Directory: Sales, Marketing, and GroupsGroups.
  • The Britta Simon and Anna Ringdahl user accounts reside in the Sales OU.
  • The Lola Jacobson and John Smith user accounts reside in the Marketing OU.
  • The Groups OU is where our groups from Microsoft Entra ID are provisioned.

:::image type="content" source="../media/common-scenarios/group-writeback-1.png" alt-text="Diagram of group writeback with cloud sync." lightbox="../media/common-scenarios/group-writeback-1.png":::

Users

This example uses the following environment:

  • A cloud-managed test user in Microsoft Entra ID.
  • A target organizational unit, for example OU=test,DC=Contoso,DC=com.
  • A writable target Active Directory user attribute, such as extensionAttribute1.

You can use the environment you create in this article for testing or for getting more familiar with cloud sync.

Create two groups inInstall and connect Microsoft Graph PowerShell SDK

  1. If not yet installed, follow Microsoft Graph PowerShell SDK documentation to install the main modules of Microsoft Graph PowerShell SDK: Microsoft.Graph.

  2. Open PowerShell with Administrative privileges.

  3. To set the execution policy, run (press [A] Yes to all when prompted):

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  4. Connect to your tenant (be sure to accept on-behalf of when signing in):

    Connect-MgGraph -Scopes "Directory.ReadWrite.All", "Application.ReadWrite.All", "User.ReadWrite.All", "Group.ReadWrite.All"
    

Create the CloudSyncCustomExtensionsApp application and service principal

Both examples store their extension on the same application, so you only need to do this once.

  1. Get the Tenant ID:

    $tenantId

  1. To begin,Using the $tenantId variable from the previous step, check to see if the CloudSyncCustomExtensionsApp exists.

    $cloudSyncCustomExtApp = Get-MgApplication -Filter "identifierUris/any(uri:uri eq 'api://$tenantId/CloudSyncCustomExtensionsApp')"
    $cloudSyncCustomExtApp
    
  2. If a CloudSyncCustomExtensionsApp exists, skip to the next step. Otherwise, create the new CloudSyncCustomExtensionsApp app:

    $cloudSyncCustomExtApp = New-MgApplication -DisplayName "CloudSyncCustomExtensionsApp" -IdentifierUris "api://$tenantId/CloudSyncCustomExtensionsApp"
    $cloudSyncCustomExtApp
    
  3. Check if the CloudSyncCustomExtensionsApp application has a service principal associated. If you just created a new app, skip to the next step.

    Get-MgServicePrincipal -Filter "AppId eq '$($cloudSyncCustomExtApp.AppId)'"
    
  4. If you just created a new app, or a service principal isn't returned, create a service principal for CloudSyncCustomExtensionsApp:

    New-MgServicePrincipal -AppId $cloudSyncCustomExtApp.AppId
    

Prepare the objects to provision

Groups

Create two groups in Microsoft Entra ID. One group is Sales and the Otherother is Marketing.

To create two groups, follow these steps.

  1. Sign in to the Microsoft Entra admin center as at least a Hybrid Identity Administrator.
  2. Browse to Entra ID > Groups > All groups.
  3. At the top, select New group.
  4. Make sure the Group type is set to security.
  5. For the Group Name, enter Sales.
  6. For Membership type, keep it at assigned.
  7. Select Create.
  8. Repeat this process using Marketing as the Group Name.Name.

Add

Now add users to the newly created groups

you created.
  1. Sign in to the Microsoft Entra admin center as at least a Hybrid Identity Administrator.
  2. Browse to Entra ID > Groups > All groups.
  3. At the top, in the search box, enter Sales.
  4. Select the new Sales group.
  5. On the left, select Members.
  6. At the top, select Add members.
  7. At the top, in the search box, enter Britta Simon.
  8. Put a check next to Britta Simon and Anna Ringdahl, and then select Select.
  9. It should successfully add her to the group.
  10. On the far left, select All groups and repeat this process using the Marketing group andgroup, adding Lola Jacobson and John Smith to that group..

Users documentation

Identify the cloud-managed user you want to install the main modules of Microsoft Graph PowerShell SDK: Microsoft.Graph.

  • Open PowerShell with Administrative privileges

  • To set the execution policy, run (press [A] Yesprovision to all when prompted):

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  • Connect to your tenant (Be sure to accept on-behalf of when signing in):

    Connect-MgGraph -Scopes "Directory.ReadWrite.All", "Application.ReadWrite.All", "User.ReadWrite.All, Group.ReadWrite.All"
    
  • Create our CloudSyncCustomExtensionApp applicationActive Directory, and service principal

    1. Get the Tenant ID:

      $tenantId

    1. Using the $tenantId variable from the previous step, check to see if the CloudSyncCustomExtensionApp exists.confirm you can retrieve it:

      $cloudSyncCustomExtApptestUser = Get-MgApplicationMgUser -Filter "identifierUris/any(uri:uriuserPrincipalName eq 'api://$tenantId/CloudSyncCustomExtensionsApp<test-user-UPN>')"
      $cloudSyncCustomExtApp$testUser
      

      You can optionally bring the user into scope through a group instead of selecting the user directly:

      1. Create an assigned Microsoft Entra security group, such as AD-Provisioning-Test.
      2. If a CloudSyncCustomExtensionApp exists, skipAdd the cloud-managed test user to the next step. Otherwise,group.

      3. Select that group when you configure user scope in cloud sync.

      Create the directory extension

      Groups

      Under the CloudSyncCustomExtensionsApp, create the extension attribute and assign it to Group objects:

      New-MgApplicationExtensionProperty -ApplicationId $cloudSyncCustomExtApp.Id -Name 'WritebackEnabled' -DataType 'Boolean' -TargetObjects 'Group'
      

      This cmdlet creates an extension attribute that looks like extension_<AppIdWithoutHyphens>_WritebackEnabled.

      Users

      Under the CloudSyncCustomExtensionsApp, create the new CloudSyncCustomExtensionApp app:

      $cloudSyncCustomExtApp = New-MgApplication -DisplayName "CloudSyncCustomExtensionsApp" -IdentifierUris "api://$tenantId/CloudSyncCustomExtensionsApp"
      $cloudSyncCustomExtApp
      
    2. Check if CloudSyncCustomExtensionsApp application has a security principal associated. If you just created a new app, skip to the next step.

      Get-MgServicePrincipal -Filter "AppId eq '$($cloudSyncCustomExtApp.AppId)'"
      
    3. If you just created a new app or a security principal is not returned, create a security principal for CloudSyncCustomExtensionsApp:

      New-MgServicePrincipal -AppId $cloudSyncCustomExtApp.AppId
      

    Create our custom extension attribute

    1. Get the Tenant ID:

      $tenantId = (Get-MgOrganization).Id
      $tenantId
      
    2. Get the CloudSyncCustomExtensionsApp application:

      $cloudSyncCustomExtApp = Get-MgApplication -Filter "identifierUris/any(uri:uri eq 'api://$tenantId/CloudSyncCustomExtensionsApp')"
      
    3. Now, under the CloudSyncCustomExtensionApp, create the custom extension attribute called "WritebackEnabled" and assign it to GroupUser objects:

      New-MgApplicationExtensionProperty -ApplicationId $cloudSyncCustomExtApp.Id -Name 'WritebackEnabledEmployeeCode' -DataType 'BooleanString' -TargetObjects 'GroupUser'
      
    4. This cmdlet creates an extension attribute that looks like extension_<guidAppIdWithoutHyphens>_WritebackEnabled._EmployeeCode. Retrieve the generated name, because you need it when you add the attribute mapping:

      $userExtension = Get-MgApplicationExtensionProperty -ApplicationId $cloudSyncCustomExtApp.Id |
          Where-Object Name -Like '*_EmployeeCode' | Select-Object -First 1
      
      $userExtensionName = $userExtension.Name
      $userExtensionName
      

      Set the extension value

      Groups

      Set a value on the newly created property for the Marketing group.

      1. Get the extension property:

        $gwbEnabledExtAttrib = Get-MgApplicationExtensionProperty -ApplicationId $cloudSyncCustomExtApp.Id |
            Where-Object {$_.Name -Like '*WritebackEnabled'} | Select-Object -First 1
        $gwbEnabledExtName = $gwbEnabledExtAttrib.Name
        
      2. Get the Marketing group:

        $marketingGrp = Get-MgGroup -ConsistencyLevel eventual -Filter "DisplayName eq 'Marketing'"
        
      3. Set the value True for the Marketing group:

        Update-MgGroup -GroupId $marketingGrp.Id -AdditionalProperties @{$gwbEnabledExtName = $true}
        
      4. To confirm, read the property value:

        $marketingGrp = Get-MgGroup -ConsistencyLevel eventual -Filter "DisplayName eq 'Marketing'" -Property Id,$gwbEnabledExtName
        $marketingGrp.AdditionalProperties.$gwbEnabledExtName
        

      Users

      1. Set the value on the test user:

        Update-MgUser -UserId $testUser.Id -AdditionalProperties @{ $userExtensionName = "EMP-1001" }
        
      2. To confirm, read the property value:

        $testUser = Get-MgUser -UserId $testUser.Id -Property "id,displayName,$userExtensionName"
        $testUser.AdditionalProperties[$userExtensionName]
        

      Set the extension value by using Microsoft Graph Explorer

      You can set the value through Microsoft Graph Explorer instead of PowerShell. Make sure you consented to the required permission by selecting Modify permissions.

      Groups

      1. Navigate to Microsoft Graph Explorer and consent to Group.ReadWrite.All.

      2. Sign in using your tenant administrator account. A Hybrid Identity Administrator account was used to create this scenario and might be sufficient.

      3. At the top, change GET to PATCH.

      4. In the address box, enter https://graph.microsoft.com/v1.0/groups/<Group Id>.

      5. In the request body, enter:

        {
          "extension_<AppIdWithoutHyphens>_WritebackEnabled": true
        }
        
      6. Select Run query.

        :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-1.png" alt-text="Screenshot of running the graph query." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-1.png":::

      7. If done correctly, you see [].

      8. At the top, change PATCH to GET and look at the properties of the Marketing group. Select Run query. You should see the newly created attribute.

        :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-2.png" alt-text="Screenshot of group properties." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-2.png":::

      Users

      1. Navigate to Microsoft Graph Explorer and consent to User.ReadWrite.All.

      2. Sign in using your tenant administrator account.

      3. At the top, change GET to PATCH.

      4. In the address box, enter https://graph.microsoft.com/v1.0/users/<User Id>.

      5. In the request body, enter:

        {
          "extension_<AppIdWithoutHyphens>_EmployeeCode": "EMP-1001"
        }
        
      6. Select Run query.

      7. At the top, change PATCH to GET and look at the properties of the user. Select Run query. You should see the newly created attribute.


      Create ourUse the extension in your cloud sync configuration

      Groups

      1. Sign in to the Microsoft Entra admin center as at least a Hybrid Identity Administrator.

      2. Browse to Entra ID > Entra Connect > Cloud sync.

      3. Select New configuration.

      4. Select Microsoft Entra ID to AD sync.

      :::::image type="content" source="media/how-to-configure-entra-to-active-directory/entra-to-ad-1.png" alt-text="Screenshot of configuration selection." lightbox="media/how-to-configure-entra-to-active-directory/entra-to-ad-1.png":::

      1. On the configuration screen, select your domain and whether to enable password hash sync.domain. Select Create.

      :::::image type="content" source="media/how-to-configure/new-ux-configure-2.png" alt-text="Screenshot of a new configuration." lightbox="media/how-to-configure/new-ux-configure-2.png":::

      1. The Get started screen opens. From here, you can continue configuring cloud syncsync.

      2. On the left, select Scoping filters, then select Group scope > All groups.

      3. Select Edit attribute mapping and change the Target Container to OU=Groups,DC=Contoso,DC=com. Select Save.

      4. Select Add Attribute scoping filter.

      5. Type a name for the scoping filter: Filter groups with Writeback Enabled.

      6. Under Target Attribute, select the newly created attribute that looks like extension_<guidAppIdWithoutHyphens>_WritebackEnabled._WritebackEnabled.

      :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-4.png" alt-text="Screenshot of available attributes." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-4.png":::

      1. Under Operator, select IS TRUE.

      2. Select Save, and then select Save.

      3. Leave the configuration disabled and come back to it.

      Users

      1. Sign in using your tenant administrator account. A Hybrid Identity Administrator account was used to create this scenario and might be sufficient.

      2. At the top, change the GET to PATCH

      3. In the address box enter: https://graph.microsoft.com/v1.0/groups/<Group Id>

      4. In the Request body enter:

        {
          "extension_<guid>_WritebackEnabled": true
        }
        
      5. Select Run query. :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-1.png" alt-text="Screenshot of running the graph query." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-1.png":::

      6. If done correctly, you see []Microsoft Entra admin center as at least a Hybrid Identity Administrator.

      7. Now at the top, change PATCHBrowse to GETEntra ID and look at the properties of the marketing group. > Entra Connect > Cloud sync.

      8. Select Run queryNew configuration and select Microsoft Entra ID to AD sync, or open an existing configuration.

      9. Select the Active Directory domain and a healthy provisioning agent.

      10. On the left, select Scoping filters, and configure User scope. You should seeSelect the newly created attribute. :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-2.png" alt-text="Screenshot oftest user directly, or select the group properties." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-2.png":::that contains the user.

      11. Select Edit attribute mapping for users and set the Target Container to the complete Active Directory distinguished name, for example OU=test,DC=Contoso,DC=com.

      12. Add the attribute mapping:

        SettingValue
        Mapping typeDirect
        Source attributeextension_<AppIdWithoutHyphens>_EmployeeCode
        Target attributeextensionAttribute1, or another writable Active Directory user attribute
      13. Select Save.

      14. Leave the configuration disabled until you review the scope, target container, and mappings.


      Test our configurationand verify

      Groups

      [!INCLUDE sign in]

      1. Under Configuration, select your configuration.

      2. On the left, select Provision on demand.

      3. Enter Marketing in the Selected group boxbox.

      4. From the Selected users section, select some users to test. Select Lola Jacobson and John Smith.

      5. Select Provision. It should successfully provision. ::

        :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-5.png" alt-text="Screenshot of successful provision." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-5.png":::

      6. Now try with the Sales group and add Britta Simon and Anna Ringdahl. This shouldn't provision. ::provision, because the Sales group doesn't have the extension value set.

        :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-6.png" alt-text="Screenshot of provisioning being blocked." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-6.png":::

      7. In Active Directory, you should see the newly created Marketing group. ::

        :::image type="content" source="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-7.png" alt-text="Screenshot of new group in active directory users and computers." lightbox="media/tutorial-directory-extension-group-provision/directory-extension-group-provision-7.png":::

      8. You can now browse to Entra ID > Entra Connect > Cloud sync > Overview page to Reviewreview and Enable ourenable your configuration toand start synchronizing.

      Users

      [!INCLUDE sign in]

      1. Under Configuration, select your configuration.
      2. On the left, select Provision on demand.
      3. Select the test user. If you used group scope, select the group and then explicitly select the test user.
      4. Select Provision.
      5. Review the import, scope evaluation, matching, and export steps.

      Confirm the value landed in Active Directory:

      Get-ADUser -Filter "UserPrincipalName -eq '<test-user-UPN>'" -SearchBase "OU=test,DC=Contoso,DC=com" -Properties extensionAttribute1 |
          Select-Object DistinguishedName,extensionAttribute1
      

      The expected value is extensionAttribute1 = EMP-1001.

      To review the result in the provisioning logs, browse to Entra ID > Monitoring & health > Provisioning logs and filter by the test user and your cloud sync configuration. Confirm that:

      • Scope evaluation passed.
      • The user was created or matched in Active Directory.
      • Under Modified properties, the directory extension was mapped to extensionAttribute1.
      • The export operation succeeded.

      Directory extensions on users converted from Active Directory

      When you convert a user's Source of Authority to Microsoft Entra ID, the attributes that Active Directory previously owned must already be visible in Microsoft Entra ID, either as directory attributes or as directory schema extensions. For the full list of preconditions, see Prepare your environment to convert user Source of Authority.

      That means a converted user usually already has the extension values it needs, so you don't create new extensions for those attributes. Instead, you map from the extensions that already hold the values.

      Extensions created by Microsoft Entra Connect live on the Tenant Schema Extension App, which is supported as a mapping source alongside CloudSyncCustomExtensionsApp. Add the mapping the same way as in the Users tab, selecting the existing extension as the source attribute. Converting Source of Authority doesn't require you to re-register or recreate the extension.

      Next stepsstep

      [!div class="nextstepaction"] Test and enable provisioning

      Related content

    Daily Entra.News

    Get daily email updates

    Get a concise summary of the latest Microsoft Entra updates delivered straight to your inbox.

    Loading the secure signup form…