In times of troubleshooting client-side issues, it may become necessary to query for the autodiscover response the user is receiving from either Exchange on-premises or Exchange in O365 – or, in the case of a redirection, both on-premises and O365 Exchange. This is a sample C#.NET Console Application, which will query for the Autodiscover response and use the TraceListener class to write the response to files.
There are two things the code doesn't take into account for:
1. The condition wherein the user's SMTP address and UPN are different.
2. ALL of the possible returns from Autodiscover for the UserSettings.
Thus, I have included the the source code for two reasons:
1. Promotion of writing .NET programs for both on-premises Exchange and O365 Exchange.
2. Customization of both the UserSettings one is targeting and the target delivery folder for which the files should be saved.
If you have any problems, questions, or concerns, feel free to reach out to me and I'll try to address them as soon as possible.
The source code can be found here: http://gallery.technet.microsoft.com/C-EWS-Autodiscover-Test-870b4a8e