Table of Contents

About Exchange 2016 transport agents

Basically it is the same as in Exchange 2013. In E16 Microsoft combined the CAS and MBX roles into one single role you can select to install, but the Frontend / Hub Transport principle is the same. So read about it here: About Exchange 2013 transport agents.

I tested this agent on a standard 1-server E16 installation.

What you need to configure in Exchange 2016

For every configured re-routing domain or specific sender email address, you need to have a corresponding Send Connector (that preferrably has a cost below the default Send Connector for "*").

E.g. if you configure sender domain mydomain.com or sender email address john.doe@mydomain.com to override routing to mydomain.sbr (the rerouting domains do not need to have a valid tld, I chose .sbr), you need to configure a Send Connector to route mails to mydomain.sbr to your mailgateway of choice.

Remember, it does not rewrite the recipient, just uses the re-routing domain to route the mail to the configured Send Connector.

Installing Binary

Create directory:
%ExchangeInstallPath%\TransportRoles\agents\Custom

• Copy Microsoft.Exchange.SBR.dll or your own compiled dll to this directory
To compile yourself, see How to compile it with your own Exchange version dlls.

• Precompiled Microsoft.Exchange.SBR.dll binaries:
  Exchange 2016 RTM, dll file versions 15.1.255.42
  Exchange 2016 CU8, dll file versions 15.1.1415.2, compiled with .NET Target Framework 4.7.1 which is supported from CU8 and mandatory from CU10 onwards anyways
  Exchange 2016 CU10, dll file versions 15.1.1531.4, with Sec. Upd. KB4340731 installed
  Exchange 2016 CU12, dll file versions 15.1.1713.1 (Common) & 15.1.1713.3 (Transport), compiled with .NET Target Framework 4.7.2 which is supported from CU11
  Exchange 2016 CU15, dll file versions 15.1.1913.7, with Sec. Upd. KB4536987 installed, compiled with .NET Target Framework 4.8
  Exchange 2016 CU23 Oct23SU, dll file versions 15.1.2507.34, compiled with .NET Target Framework 4.8
  Exchange 2016 CU23 Nov23SU, dll file versions 15.1.2507.35, compiled with .NET Target Framework 4.8

(Unblock the dll in its file properties once extracted from the ZIP file)

Configuring SBR Transport Agent

Create OverrideSettings Config

Create Microsoft.Exchange.SBR.OverrideSettings.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [original_internal_domain_or_individualsender];[re-routing_domain]
mydomain.com;mydomain.sbr
john.doe@myotherdomain.com;myotherdomain.sbr
#notused.com;notused.sbr


• Empty lines and commented lines (with preceding #) are allowed

Create InternalDomains Config

Create Microsoft.Exchange.SBR.InternalDomains.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [internal_domain]
mydomain.com
myotherdomain.com
#notused.com


• Create this file even if it remains empty!
• If it remains empty, each mail of every configured re-routing domain or specific sender email address is sent to the appropriate mailgateway, even if the recipient is from the same (or any other) internal domain. Maybe this is even a wanted behaviour.
• Otherwise list every internal recipient domain the agent should know about to be able to send fully resolvable Exchange objects between them (using the ABP Routing Agent).
• Empty lines and commented lines (with preceding #) are allowed

Create IgnoreAuthAs Config

Create Microsoft.Exchange.SBR.IgnoreAuthAs.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [Ignore_AuthAs_Header]
Anonymous
External
Partner


• If not at least Anonymous is in this list, loops will be created for internal sender/recipient combinations that have not an equal GroupID
Internal should never be in this list, these mails are to be evaluated in the first place
Internal are sent from withing Exchange org, e.g. Outlook/OWA/ActiveSync etc. Anonymous come from Outside. I'm honestly not 100% sure yet about External and Partner, haven't seen those values yet.
• Agent checks X-MS-Exchange-Organization-AuthAs header value against this list and ignores message if value is in list
• See list of Exchange organization X-headers at Understanding Header Firewall
• Empty lines and commented lines (with preceding #) are allowed

Enabling Event Logging

How to enable this agent for Event Logging

• Open command prompt, navigate to the following location (or equivalent based on your .NET installation):
  %windir%\Microsoft.NET\Framework64\v4.0.30319
  (if not sure, check where the InstallUtil.exe and EventLogMessages.dll files are)
• Execute:
  InstallUtil.exe "C:\Program Files\Microsoft\Exchange Server\v15\Transport Roles\agents\Custom\Microsoft.Exchange.SBR.dll"
  (This step only needs to be done once)
• Set event logging level in Registry at:
  HKLM\SYSTEM\CurrentControlSet\services\MSExchangeSbrAgent\Diagnostics
  DWORD "General"
• Logging Levels (each level includes messages from lower levels):
  0:   Default: No logging
  1:   For each rerouted message, log for how many recipients it was rerouted
  2:   For each rerouted message, log the individual recipients for whom it was rerouted
  3:   For each rerouted message, log sender domain or email address found in rerouting table;
       Log exception information on agent error
  4:   Log start message handling;
       Log end message handling when nothing to do;
       Log exit message handling
  5:   Log X-MS-Exchange-Organization-AuthAs header value (Internal/Anonymous)
  6:   Show event logging level on each started instance of agent
  >=7: (not used)
• All event log entries include the Message ID and the subject.

Installing SBR Transport Agent on Exchange 2016

How to install this custom transport agent

• Open Exchange Management Shell
• Execute:
Install-TransportAgent "Sender Based Routing" -TransportAgentFactory "Microsoft.Exchange.SBR.SbrRoutingAgentFactory" -AssemblyPath "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\agents\Custom\Microsoft.Exchange.SBR.dll" -TransportService Hub
• Restart Exchange Management Shell
• Execute: Restart-Service MSExchangeTransport

Installing ABP Routing Agent on Exchange 2016

How to install included transport agent

This new ABP Routing Agent ships since Exchange 2013 CU1. It solves the problem for fully resolvable Exchange objects if members of different ABPs sent mails to eachother.

Microsoft:
Address Book Policies, Jamba Jokes and Secret Agents
So what we have done is create an agent, which when enabled, and I’m explaining this at a very high level, examines each message submitted by a user, and looks up the ABPs of any recipients it finds, and buckets or groups the message by ABP, and then performs recipient resolution on them using the GAL specified within the ABP, not the entire directory, before it delivers the message.

How to install this included transport agent:

• Open Exchange Management Shell
• Execute:
Install-TransportAgent -Name "ABP Routing Agent" -TransportAgentFactory "Microsoft.Exchange.Transport.Agent.AddressBookPolicyRoutingAgent.AddressBookPolicyRoutingAgentFactory" -AssemblyPath "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\agents\AddressBookPolicyRoutingAgent\Microsoft.Exchange.Transport.Agent.
AddressBookPolicyRoutingAgent.dll"

• Restart Exchange Management Shell
• Execute: Restart-Service MSExchangeTransport

Enabling SBR Transport Agent on Exchange 2016

How to enable this custom transport agent

• Open Exchange Management Shell
• Execute: Enable-TransportAgent "Sender Based Routing" -TransportService Hub
• Execute: Restart-Service MSExchangeTransport
• Check Transport Agents: Get-TransportAgent

Enabling ABP Routing Agent on Exchange 2016

How to enable included transport agent

• Open Exchange Management Shell
• Execute: Enable-TransportAgent "ABP Routing Agent"
• Execute: Restart-Service MSExchangeTransport
• Execute: Set-TransportConfig –AddressBookPolicyRoutingEnabled $True
• Check Transport Agents: Get-TransportAgent

Uninstalling SBR Transport Agent

How to disable/uninstall this custom transport agent

• Open Exchange Management Shell
• Execute: Disable-TransportAgent "Sender Based Routing" -TransportService Hub -Confirm:$false
• Execute: Restart-Service MSExchangeTransport
• To be able to replace the dll with a new version, sometimes I have to execute an iisreset now.
• Execute: Uninstall-TransportAgent "Sender Based Routing" -TransportService Hub -Confirm:$false
• Execute: Restart-Service MSExchangeTransport
• Check Transport Agents: Get-TransportAgent
• To be able to delete the dll, execute an iisreset

Uninstalling Event Logging

How to disable/uninstall event logging

To revert the changes made for event logging, just delete these two keys:

HKLM\SYSTEM\CurrentControlSet\Services\MSExchangeSbrAgent
HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\Microsoft.Exchange.SBR