Outlook users may face an issue when trying to connect to Exchange Server, where Outlook won’t start and instead shows the following error message “Cannot Start Microsoft Outlook. Cannot open the Outlook Window. The set of folders cannot be opened. The attempt to log on to Microsoft Exchange has failed

In this post, you will learn how to fix this outlook issue easily.

How legacyExchangeDN can cause issues with outlook

Multiple websites talk about the possible fix, but still no fix. Some of these fixes are related to starting Outlook in Safemode Outlook /safe or recreating the user profile… up to reinstalling Outlook itself. But in my case, none of these was the cause.

One possible cause is a white space in the Active Directory user attribute and precisely in the legacyExchangeDN attribute.

The legacyExchangeDN holds the path for the user object in the exchange organization. So, lets assume that a user is named “Faris Malaeb – (Corp System Engineering)“. The LegacyExchangeDN path should be something like

/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Faris Malaeb – (Corp System Engineering)

Note that the LegacyExchangeDN might hold other value, depend on the Exchange Server version and object history

The LegacyExchangeDN can hold up to 128 characters, so if the path is longer than what the attribute can hold, the path is truncated to be something like this.

/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Faris Malaeb – (Corp System Engineerin

Note the last few characters got truncated and removed.

This is all fine and will work unless the last character LegacyExchangeDN is a white space. For example, let assume that a user is named Faris Malaeb – ( Corp System Operator ). The LegacyExchangeDN will be

‘/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Faris Malaeb – ( Corp System Operator

See the and how its ending with a white space. This can cause outlook to fail to open the user mailbox and shows the following error message

Outlook crash

Remove LegacyExchangeDN white space using PowerShell

To fix this issue, we need to remove the white space from the end of the LegacyExchangeDN attribute. Open PowerShell and import ActiveDirectory module

The following code list all users with a white space ending in their LegacyExchangeDN

Import-Module ActiveDirectory
Get-ADUser -Properties legacyExchangeDN -Filter * |where {($_.LegacyExchangeDN.length -eq 128) -and ($_.LegacyExchangeDN.endswith(' '))}

You can replace the white space for any user using the following line of code

$FixedDN=(Get-ADUser USERNAME -Properties LegacyExchangeDN).LegacyExchangeDN -replace ".{1}$"

Conclusion

This is not the only way to fix this error, but one of the working methods I find to work.

Let me know you’re though.

So as you reach to this point, how about taking a look on the following post Add Exchange Online Mailbox to Microsoft 365 Group

5/5 - (2 votes)