The idea with DirSync is to keep your user administration on-prem. A problem arise when you decomission the on-premises Exchange server and want to create a Shared Mailbox or a Resource Mailbox. There is no simple way to create such mailbox without assigning a license. It is possible to create a new regular user, assign a license, and then convert it to a Shared Mailbox or a Resource Mailbox, but the drawback with this method is that it requires a license during the process. On the other hand your user account will be fully managed in your on-prem environment, and the goal is achieved.
Another possibility is to create a Resource Mailbox with a Cloud Identity, and then connect it to an account synced from your Active Directory. This is what I will show you now. Lets start with disabling DirSync. This step is not necessary, but we might get some problems if our accounts are synced before they are ready.
Stop-Service MSOnlineSyncScheduler
Then we create a user account in Active Directory that we will later sync to Office 365:
Import-Module ActiveDirectory $ADUserProperties = @{ Name = 'Meeting Room 1' Path = 'CN=Users,DC=365lab,DC=net' SamAccountName = 'room1' UserPrincipalName = 'room1@365lab.net' DisplayName = 'Meeting Room 1' EmailAddress = 'room1@365lab.net' OtherAttributes = @{ ProxyAddresses = 'SMTP:room1@365lab.net' } } $ADUser = New-ADUser @ADUserProperties -PassThru
The next step is to create a new Resource Mailbox in Office 365. This can be done either with GUI or PowerShell, I prefer PowerShell.
$O365cred = Get-Credential $O365sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365cred -Authentication Basic -AllowRedirection $importcmd = Import-PSSession $O365sess $O365UserProperties = @{ DisplayName = 'Meeting Room 1' Name = 'room1' } $RoomMailbox = New-Mailbox @O365UserProperties -Room
Now we have two separate accounts, one in Active Directory with the managed attributes, and one in the cloud that we want to connect to our on-prem identity. The connection is done by populating the ImmutableID attribute with the corresponding ObjectGuid from Active Directory. Also, we change the UserPrincipalName in Office 365 to match our domain account.
$ObjectGuid = $ADUser.objectGuid $ImmutableId = [System.Convert]::ToBase64String($ObjectGuid.ToByteArray()) Import-Module MSOnline Connect-MsolService Set-MsolUserPrincipalName -UserPrincipalName $RoomMailbox.UserPrincipalName -NewUserPrincipalName $ADUser.UserPrincipalName -ImmutableId $ImmutableId
Now our UserPrincipalNames are the same in both our Active Directory and in Office 365, and we have linked then together using the ObjectGuid/ImmutableId. Time to start our DirSync service again and force a synchronization to run.
Start-Service MSOnlineSyncScheduler Import-Module DirSync Start-OnlineCoexistenceSync -FullSync
Now the Cloud Identity is converted to a DirSynced Identity, and the attributes in Active Directory are syned to our new Resource Mailbox. From now on all user administration tasks for this account can be managed in our on-prem Active Directory.
/ Andreas