Redirect users with mailboxes in Office 365 from Exchange using NetScaler

I wrote a blog post about smart links to Office 365, but there’s also a way to make sure users with their mailboxes in Office 365 automatically are redirected to their Outlook Web Access there (with SSO). They key lies in using a 307 redirect instead of 301 or 302, where the post is sent to ADFS – and the username and password field (luckily) are the same in Exchange (tried it with 2013). I haven’t tried this with Windows Integrated Authentication internally, but should work just fine – but maybe needs some tweaking.

First off, as always, create the pattern sets and expressions (if not already created for your Exchange load balancing):

Next step, create the rewrite to actually redirect the user from Exchange to ADFS:

Remember to replace (it’s in a few different places) as well as the ADFS FQDN.

Now, create the rewrite policies and policy labels- and don’t forget to replace OFFICE365TENANT with your tenant name:

And as a last step, bind them to the vservers – in my case the load balancing vservers:

Leave a comment if you have any questions or if it doesn’t work – or if you have any better ways of doing this! I’ve tried it with Exchange 2013 and ADFS on 2012 R2.

Disclaimer: All information on this blog is offered "as is" with no warranty. It is strongly recommended that you verify all information and validate all scripts in isolated test environments before using them in production environments.