Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

I have a problem with extension attributes in Exchange Online that are synced from AD. I…

  1. User

    I have a problem with extension attributes in Exchange Online that are synced from AD. I want to make it so that we sync up the distinguishedname minus the common name as extension attribute 13. The end goal would be having a single extension attribute visible in Exchange that could be used to construct dynamic distribution groups based on OU placement of a user. We have currently attribute 10 with custom expression "Cstr([dn])", attribute 11 with expression "DNComponent(CRef([dn]),2" and attribute 12 with expression "DNComponent(CRef([dn]),3". Please suggest a way to set up attribute 13 to have a full DN of an user minus their CN which is the first part of the DN and since it's unique we don't want it.

  2. Assistant

    To configure extensionAttribute13 to contain the distinguished name (DN) minus the common name (CN), you can use a custom expression in Azure AD Connect's synchronization rules. This will allow you to synchronize the portion of the DN that represents the organizational unit (OU) structure, excluding the unique CN of the user. Here's how you can set it up:

    Custom Expression for extensionAttribute13

    Set the Attribute to extensionAttribute13 and use the following Custom Expression:

    Mid(CStr([dn]), Len(DNComponent(CRef([dn]),1)) + 2)
    

    Explanation of the Expression

    1. CStr([dn]):

      • Converts the distinguished name (DN) of the object to a string.
      • Example: "CN=John Smith,OU=Sales,OU=North America,DC=Contoso,DC=Com"
    2. DNComponent(CRef([dn]),1):

      • Retrieves the first component of the DN, which is the CN (Common Name).
      • Result: "CN=John Smith"
    3. Len(DNComponent(CRef([dn]),1)):

      • Calculates the length of the first DN component (the CN).
      • If "CN=John Smith" has 13 characters, Len returns 13.
    4. Len(DNComponent(CRef([dn]),1)) + 2:

      • Adds 2 to account for the comma , separator between DN components.
      • This ensures the starting position skips over the CN and the comma.
      • Calculation: 13 (length of CN) + 2 = 15
    5. Mid(CStr([dn]), Len(DNComponent(CRef([dn]),1)) + 2):

      • Extracts the substring from the DN starting at position 15 to the end.
      • This effectively removes the CN and the comma, leaving the rest of the DN.
      • Result: "OU=Sales,OU=North America,DC=Contoso,DC=Com"

    Steps to Implement in Azure AD Connect

    1. Open Synchronization Rules Editor:

      • Launch the Synchronization Rules Editor from your Azure AD Connect installation.
    2. Create a New Synchronization Rule:

      • Click on "Add new rule".
      • Provide a name for the rule (e.g., "Populate extensionAttribute13 with DN minus CN").
      • Select the appropriate Connected System (your on-premises AD).
      • Set Direction to "Inbound".
      • Specify the User object type.
    3. Configure Attribute Flow:

      • In the Transformation section, add a new attribute flow.
      • FlowType: Direct
      • Target Attribute: extensionAttribute13
      • Mapping Type: Expression
      • Source: Paste the custom expression:
        Mid(CStr([dn]), Len(DNComponent(CRef([dn]),1)) + 2)
        
    4. Save and Apply the Rule:

      • Click "Save" to create the synchronization rule.
      • Ensure that the rule has a priority that places it appropriately in the synchronization order.
    5. Run a Full Synchronization:

      • After saving the new rule, perform a Full Synchronization to apply changes.
      • Use the Azure AD Connect tool or run the following commands in PowerShell:
        Start-ADSyncSyncCycle -PolicyType Initial
        
        • Note: A Full Sync is necessary because changes to synchronization rules aren't applied during delta synchronizations.

    Final Result

    After synchronization completes, the extensionAttribute13 for each user will contain their DN without the CN. For example:

    • Original DN:
      CN=John Smith,OU=Sales,OU=North America,DC=Contoso,DC=Com
      
    • extensionAttribute13:
      OU=Sales,OU=North America,DC=Contoso,DC=Com
      

    Usage in Exchange Online

    With extensionAttribute13 populated, you can now create Dynamic Distribution Groups in Exchange Online based on the OU placement of users. When defining recipient filters for dynamic groups, you can reference extensionAttribute13 to include or exclude users from specific OUs.

    Additional Notes

    • Testing: Before implementing in production, test the synchronization rule with a few test accounts to ensure it behaves as expected.
    • Custom Expressions: Ensure that any custom expressions are carefully validated, as errors can cause synchronization issues.
    • Limitations: Keep in mind that changes to synchronization rules may impact synchronization performance during the initial full sync.

    References

    By following these steps, you'll have extensionAttribute13 populated with the DN minus the CN, enabling more flexible and OU-based group management in Exchange Online.