Use AADConnect to Populate Office 365 Usage Location
So, a million years and tens of thousands of lines of code ago, I wrote a script for a customer to populate the Office 365 UsageLocation property (Set-MsolUser -UsageLocation) with the ISO country codes from Active Directory. In Office 365, UsageLocation is used to determine what features are available to your users.
If you have the Country Code populated in Office 365, we can flow that value in to Azure AD. But what if you *don't* have a country code set for everyone and just want it to be set to US if it's blank?
Here's a rule that will do just that.
- Launch the Synchronization Rules Editor.
- Under Rule Types, click Inbound, and then click Add New Rule.
- Under Connected System, select the connector that represents your Active Directory.
- Make the following selections:
- Connected System Object Type: user
- Metaverse Object Type: person
- Link Type: Join
- Precedence: <any value lower than the default rules >
- Click Next.
- On the Scoping Filter page, click Next.
- On the Join Rules page, click Next.
- On the Transformations page, do one of the following:
- If you want everyone to get the same usage location regardless of country code in Office 365, make the following selections:
- Flow Type: Constant
- Target Attribute: usageLocation
- Source: US
- If you want to only flow a certain value if the field is blank, make the following selections:
- Flow Type: Expression
- Target Attribute: usageLocation
- Source: IIF(IsNullOrEmpty([c]),"US",[c])
- If you want everyone to get the same usage location regardless of country code in Office 365, make the following selections:
- Click Save.
Word to the wise: If you are populating AD with the country code value, make sure you are using the appropriate ISO 3166-2 country code.
Comments
- Anonymous
July 25, 2016
Thanks - Anonymous
June 07, 2017
The comment has been removed- Anonymous
June 08, 2017
The comment has been removed- Anonymous
June 08, 2017
Hi Aaron,Thanks for that useful info. I will have a go, you understood the situation perfectly so I am sure your method will work.Cheers
- Anonymous
- Anonymous
- Anonymous
June 19, 2017
The comment has been removed- Anonymous
June 27, 2017
So, c -> c in inbound rules 104, 105, 106, and 107. UsageLocation is actually mapped from msExchUsageLocation in another rule. If you take the rule example I have and use a flow type of Constant and select the source attribute as c and target attribute as usageLocation, that should achieve your goal.
- Anonymous
- Anonymous
June 21, 2017
Attempted the 2nd Option and it returns a error,The Expresion for the following mappings contain attributes that are note defined in the source schema:destination attribute : usagelocationSource Attribute(s): c,c" should I change the Source attribute "- Anonymous
June 26, 2017
I just re-created it in my lab, and it still works. Make sure you copy/paste the expression into the Source column:IIF(IsNullOrEmpty([c]),"US",[c])It evaluates like this:If the value in [c] is null or empty, put the value "US" in. Otherwise, use the value present in [c]. It is case-sensitive, so if you have a capital C somewhere in there, you will generate that error.
- Anonymous
- Anonymous
June 29, 2017
The comment has been removed- Anonymous
July 10, 2017
The comment has been removed
- Anonymous
- Anonymous
September 08, 2017
Whenever I try to do either of these string, saving the transformation gives me an error "Object Reference not set to an instance of an object" - Office 365 support has been no help as well, can anyone assist?- Anonymous
September 08, 2017
I believe there's a bug in some versions of AAD Connect when creating the rules right now via GUI. You'll need to populate a value in the Tag field. You can just put a space character there, and the rule should save fine. The bug should have been corrected in the latest version of AAD Connect, 1.1.614.0.
- Anonymous