Outlook Autodiscover

I can’t seem to get my Autodiscover configuration to please the official Microsoft Outlook Autodiscover tester. It locates Autodiscover.xml ok, but then throws an xml error that I’m not sure what to do with:

Message: <clientConfig xmlns=''> was not expected. Type: System.InvalidOperationException

Anybody know what this might mean? I’ve tested it with my custom Autodiscover.xml as well as the Virtualmin default and it does the same thing.

Full error follows:

[code] Attempting to send an Autodiscover POST request to potential Autodiscover URLs.
Autodiscover settings weren’t obtained when the Autodiscover POST request was sent.

Additional Details

Elapsed Time: 824 ms.

Test Steps

The Microsoft Connectivity Analyzer is attempting to retrieve an XML Autodiscover response from URL https://my.domain.com:443/Autodiscover/Autodiscover.xml for user user@domain.com.
The Microsoft Connectivity Analyzer failed to obtain an Autodiscover XML response.

Additional Details

The Autodiscover XML response received by the Microsoft Connectivity Analyzer was invalid. Exception: Exception details:
Message: There is an error in XML document (3, 2).
Type: System.InvalidOperationException
Stack trace:
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at Microsoft.Exchange.Tools.ExRca.Tests.AutoDiscover.AutoDiscoverGetXMLBase`2.Discover()
Exception details:
Message: <clientConfig xmlns=''> was not expected.
Type: System.InvalidOperationException
Stack trace:
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOutlookAutoDiscoverResponse	XML.Read11_Autodiscover()
HTTP Response Headers:
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml
Date: Sun, 27 Jul 2014 20:35:51 GMT
Server: Apache/2.2.22 (Debian)
Elapsed Time: 823 ms. [/code]

That’s an odd error, as it seems to be referring to the clientConfig XML tag which is used for firefox.

What exact URL are you passing to the autodiscover validation tool?

I don’t directly pass the URL. Using the Microsoft Remote Connectivity Analyzer, I select Outlook Autodiscover from a bank of available tests, input an email address and a password and it attempts autodiscovery. See here: https://testconnectivity.microsoft.com

Using an SRV record, it eventually determines the location of the xml file to be https://hq.innovenn.com/Autodiscover/Autodiscover.xml and then it pouts about the syntax.

I wouldn’t complain about its failure since Outlook is currently working, but I understand many other devices use Autodiscover as well, and currently neither Mac Mail or iOS Mail receive settings, so I thought perhaps Outlook was just being extra helpful.

Can you check what pages the autodiscovery test accesses when you use it? They should appear in the domain’s web log, under the /var/log/virtualmin directory.

I’m interested to know if it is accessing anything other than the path Virtualmin expects, and if so with what HTTP request type.

Here are the two lines that show up in the access log when I run the test. Nothing new in the error log.

157.56.138.141 - - [29/Jul/2014:22:52:21 -0500] “POST /Autodiscover/Autodiscover.xml HTTP/1.1” 200 1988 “-” “Microsoft Office/15.0 (Windows NT 6.2; Microsoft Outlook 15.0.4615; Pro; MS Connectivity Analyzer)”
157.56.138.141 - - [29/Jul/2014:22:52:27 -0500] “POST /Autodiscover/Autodiscover.xml HTTP/1.1” 200 1350 “-” “Microsoft Office/15.0 (Windows NT 6.2; Microsoft Outlook 15.0.4615; Pro; MS Connectivity Analyzer)”

Ok, I see the issue here - the tester uses a URL in which “discover” has a lower-case D, but Virtualmin expects it to be like AutoDiscover. I guess this works on Windows webservers, as their filesystem is case-insensitive!

I’ll fix this in the next release.

I don’t know if this affects your idea or not, but I did notice originally that the tester (and I think Outlook 2010 as well) were searching for Autodiscover/Autodiscover.xml and I added a third ScriptAlias in the apache directives to handle that case:

ScriptAlias /AutoDiscover/AutoDiscover.xml /home/innovenn.com/cgi-bin/autoconfig.cgi ScriptAlias /autodiscover/autodiscover.xml /home/innovenn.com/cgi-bin/autoconfig.cgi ScriptAlias /Autodiscover/Autodiscover.xml /home/innovenn.com/cgi-bin/autoconfig.cgi

I am getting using the MS tester:

The Response element in the payload was null.

<?xml version="1.0"?> HTTP Response Headers: Vary: Accept-Encoding Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/xml Date: Thu, 02 Oct 2014 18:06:19 GMT Server: Apache/2.4.7 Elapsed Time: 487 ms.

Yet if I go in to autoconfig.pl and change print << EOF to warn <<EOF so that I get the output into apache error log, everything looks good to me.

Any ideas?

I am getting using the MS tester:

The Response element in the payload was null.

<?xml version="1.0"?> HTTP Response Headers: Vary: Accept-Encoding Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/xml Date: Thu, 02 Oct 2014 18:06:19 GMT Server: Apache/2.4.7 Elapsed Time: 487 ms.

Yet if I go in to autoconfig.pl and change print << EOF to warn << EOF so that I get the output into apache error log, everything looks good to me.

Any ideas?

Same problem…

Mensaje: was not expected. Tipo: System.InvalidOperationException 157.56.138.141 - - [25/May/2015:18:59:15 -0500] "POST /Autodiscover/Autodiscover.xml HTTP/1.1" 200 6006 "-" "Microsoft Office/15.0 (Windows NT 6.2; Microsoft Outlook 15.0.4615; Pro; MS Connectivity Analyzer)" 157.56.138.141 - - [25/May/2015:18:59:16 -0500] "POST /Autodiscover/Autodiscover.xml HTTP/1.1" 200 1327 "-" "Microsoft Office/15.0 (Windows NT 6.2; Microsoft Outlook 15.0.4615; Pro; MS Connectivity Analyzer)"

Virtualmin version 4.17

Please help

Any comment???

Help!

Several months later…I’ve encountered this problem again, but it suddenly makes sense to me!

I believe the issue is in the cgi-bin/autoconfig.cgi script with dynamically produces an xml file suitable for Outlook or for Thunderbird depending on the client query (see the “Output the XML” section of autoconfig.cgi)

It says basically “If client requests autodiscover.xml, return the Outlook-flavored XML, beginning with <Autodiscover xmlns etc etc, otherwise return the Thunderbird-flavored XML, beginning with <clientConfig version etc etc”

I think this conditional doesn’t take into account the possibility that autodiscover.xml may be spelled several different ways depending on the client, e.g. Autodiscover.xml and AutoDiscover.xml and when we see was not expected, it’s because the script is feeding Thunderbird xml to Outlook.

When I changed the line

if ($ENV{‘SCRIPT_NAME’} =~ /autodiscover.xml/) {

to

if ($ENV{‘SCRIPT_NAME’} =~ /Autodiscover.xml/) {

then Outlook autodiscovered properly…but Thunderbird no longer could. So it seems we need a more sophisticated conditional to handle all possible spellings.

You’re right, outlook can use either of those URLs. I will fix this in the next Virtualmin release to use :

if ($ENV{'SCRIPT_NAME'} =~ /autodiscover.xml/i) {

which does a caseless match.

So … after having spent hours chasing my tail from the standpoint of a Windows and Exchange Server admin trying to figure out why one of my Exchange domains was no longer keeping settings for traveling users I stumbled on this page.

The whole idea, from a Windows perspective, behind using VIrtualMin for us is to NOT have to spend hours looking at code with which we only have a nodding relationship.

Could there be a way to disable this by default for new sites, without having to dig through Apache Directives? I use a point and click interface so as to NOT have to dig through pages of Apache, et. al., config files looking for arcane settings.