How to update the username within Office 365 (with AD Connect Synced)

So let’s say you are doing a migration from the local exchange server to Office 365 and you forgot to update the UPN field in Active Directory to match the domain of the email address. If this happens, you need to update the username within Office 365.  Fortunately, I can show you how to do this using PowerShell.

The way Microsoft AD Connect sync utility works is it reads the Pre-2000 username found in Active Directory.  This traditionally ends in “.local”.  Therefore, it tries to sync the UPN attribute as your local domain, (i.e. domain.local).  This doesn’t match your email domain. Because of this, Microsoft AD Connect sync defaults the username in Office 365 to be the onmicrosoft.com subdomain.  This is especially irritating when it did this the first time you were performing a sync and just learning how it worked.  (Hint: that was me a year and a half ago)

How to update the username within Office 365

Now I have learned a lot more about the AD Connect sync utility and found out that it uses the UPN attribute field in Active Directory to set the username field in Office 365.  Before, I would manually reset the UPN in Office 365 using the following Powershell command within the Azure Active Directory Module application:

Set-MsolUserPrincipalName -UserPrincipalName "[old UPN here]" -NewUserPrincipalName "[new UPN here]"

Whereas, now what I discovered needs to happen is the UserPrincipalName Attribute needs to be changed within the local ADSI Edit utility.  Once that is changed and the next sync happens, it will update the username within Office 365.

update the username within Office 365

I hope this was helpful for someone in understanding how to update the username within Office 365  within an AD Synced environment.

Leave a reply