Site icon Franky's Web

Quick & Dirty: IMCEAEX Strings in X500 konvertieren

I had this problem before in a other articles described: Users receive an undeliverability report (NDR) when attempting to send to mailboxes or distribution lists. The field code in the NDR is "550 5.1.1 RESOLVER.ADR.ExRecipNotFound; not found'. Here is an example of such an NDR:

The problem occurs, for example, when a distribution list has been migrated to a shared mailbox. The e-mail address remains the same, but the "LegacyExchangeDN" changes. Outlook still uses this attribute for auto-completion. If a user has already sent mails to a distribution list and therefore saved the entry in their autocomplete, the NDR shown above occurs after the change (in this case distribution list to shared mailbox).

If it only affects a few users, the old entry can simply be deleted:

However, if it affects many users, this is probably no longer an option. As described in the article linked above, the LegacyExchangeDN can be assigned as an X500 entry to the new distribution list or mailbox to avoid the problem.

However, if you no longer have the old LegacyExchangeDN, the IMCEAEX string from the NDR can also be converted into an X500 entry and assigned.

This small PowerShell function converts the IMCEAEX string into X500 strings:

function ConvertTo-X500{
 
    Param(
    [parameter(Mandatory=$true)]
    [String]
    $IMCEAEX 
    )
 
	$IMCEAEX = $IMCEAEX.replace("_","/")
	$IMCEAEX = $IMCEAEX.replace("+20"," ")
	$IMCEAEX = $IMCEAEX.replace("+28","(")
	$IMCEAEX = $IMCEAEX.replace("+29",")")
	$IMCEAEX = $IMCEAEX.replace("+40","@")
	$IMCEAEX = $IMCEAEX.replace("+2E",".")
	$IMCEAEX = $IMCEAEX.replace("+2C",",")
	$IMCEAEX = $IMCEAEX.replace("+5F","_")
	$IMCEAEX = $IMCEAEX.replace("IMCEAEX-","X500:")
	$IMCEAEX = $IMCEAEX.split("@")[0]
	
	return $IMCEAEX
}

The function can now be used in scripts or directly in the PowerShell:

In this small example, an IMCEAEX string from an NDR is converted into an X500 entry and then assigned to the mailbox:

$MailboxAlias = "frank"
$IMCEAEXString = "IMCEAEX-_O=Frankys+20Web_OU=EXCHANGE+20ADMINISTRATIVE+20GROUP+20+28FYDIBOHF23SPDLT+29_CN=RECIPIENTS_CN=Zoechling+20SFrankd9c@frankysweb.local"

function ConvertTo-X500{
 
    Param(
    [parameter(Mandatory=$true)]
    [String]
    $IMCEAEX 
    )
 
	$IMCEAEX = $IMCEAEX.replace("_","/")
	$IMCEAEX = $IMCEAEX.replace("+20"," ")
	$IMCEAEX = $IMCEAEX.replace("+28","(")
	$IMCEAEX = $IMCEAEX.replace("+29",")")
	$IMCEAEX = $IMCEAEX.replace("+40","@")
	$IMCEAEX = $IMCEAEX.replace("+2E",".")
	$IMCEAEX = $IMCEAEX.replace("+2C",",")
	$IMCEAEX = $IMCEAEX.replace("+5F","_")
	$IMCEAEX = $IMCEAEX.replace("IMCEAEX-","X500:")
	$IMCEAEX = $IMCEAEX.split("@")[0]
	
	return $IMCEAEX
}

$ProxyAddresses = (Get-Mailbox $MailboxAlias).EmailAddresses
$x500 = ConvertTo-X500 -IMCEAEX $IMCEAEXString
$x500 =  [Microsoft.Exchange.Data.CustomProxyAddress]("$x500")
$ProxyAddresses += $x500
Set-Mailbox $MailboxAlias -EmailAddresses $ProxyAddresses

The script can also be adapted for distribution lists with little effort.

Exit mobile version