6.0.0-beta1
7/19/25

[#11639] ActiveSync :: Extend the Autodiscover feature to return also valid answers to MS Outlook queries
Summary ActiveSync :: Extend the Autodiscover feature to return also valid answers to MS Outlook queries
Queue Horde Framework Packages
Queue Version Git develop
Type Enhancement
State Resolved
Priority 1. Low
Owners mrubinsk (at) horde (dot) org
Requester torben (at) dannhauer (dot) info
Created 11/04/2012 (4640 days ago)
Due
Updated 11/16/2012 (4628 days ago)
Assigned
Resolved 11/16/2012 (4628 days ago)
Milestone
Patch Yes

History
11/16/2012 12:55:10 PM Michael Rubinsky State ⇒ Resolved
 
11/16/2012 07:30:24 AM torben (at) dannhauer (dot) info Comment #27 Reply to this comment
Now?
Autodiscover works for Outlook 2010 and iOS 6.0.1 ! :)

I'll test Outlook 2013 at home this evening, but I strongly assume 
this feature is finally implemented.

Regarding Outlook 2013:
My last impression was, that Outlook 2013 performs to independent queries:
the autodiscover for Imap & Co followed by the autodiscover for activesync.

In my opinion Microsoft should have sorted their autodiscover attempts 
from the most capable protocol (activesync: email, contacs and 
calenders) to the least capable protocol (imap: only email) to 
establish the "best" connection the server/client can achieve. But it 
doesn't.
So the question is if horde should address this MS bug and should 
return for Outlook 2013 only activesync repsonses? I'm not sure. But 
that could be adressed once horde supports EAS 14.

Anyway, the autodiscover for outlook works great, so I'm looking 
forward to see it integrated into the next release.

Torben





11/15/2012 04:05:36 PM Michael Rubinsky Comment #26 Reply to this comment
Now?
11/15/2012 03:57:49 PM Michael Rubinsky Comment #25 Reply to this comment
I misunderstood what you were telling me about the multiple requests 
that outlook makes. The idea was to catch the mobilesync request 
made by Outlook and reject it, but I now see that the request from 
Outlook for mobilesync looks like any other mobilesync request. I'll 
have to check the useragent, which I was hoping to avoid since 
future versions of Outlook can have different values for this.
Actually, on second thought. I shouldn't have to sniff this out at 
all. It's up to the client to know if the server supports the version 
number required by the client. Outlook should detect this and refuse 
to use EAS. This is what I'll implment, you'll have to let me know if 
this works, since I don't have an Outlook client to use to test.
11/15/2012 03:54:33 PM Michael Rubinsky Comment #24 Reply to this comment

[Show Quoted Text - 23 lines]
Line 113 checks for an empty *request* schema. It's needed because 
some broken android clients don't send the XML payload at all. So, we 
default to the assuming a mobilesync *request* schema.
- Line 135 opens a conditionalblock for the "autodiscover/outlook" 
schema, so within this block, it does not make sense to check for a 
mobilesync schema as done in lines 140:144. -> what was the 
intention of the line? In my opinion we must drop that lines, 
because the comparison in line 140 is always true and thus the 
function returns a failure response.
I misunderstood what you were telling me about the multiple requests 
that outlook makes. The idea was to catch the mobilesync request made 
by Outlook and reject it, but I now see that the request from Outlook 
for mobilesync looks like any other mobilesync request. I'll have to 
check the useragent, which I was hoping to avoid since future versions 
of Outlook can have different values for this.
Bye the way:
the failure response has always  the response schema for a 
mobilesync, so RCA seems not to unterstand that an error occured. 
the _buildFailureResponse(..) function should use the correct 
response schema in line 216 to allow Outlook & RCA to unterstand 
that the error code is the response to teir query.
Ok. Thanks for the info. Will fix.
Torben
11/15/2012 03:38:54 PM torben (at) dannhauer (dot) info Comment #23 Reply to this comment
Hi,
The respond schema is now detected correctly for both, Outlook and RCA.


Regarding teh logic fix: Maybe I'm missing the point, but for me it 
does make still no sense.

My observation was, that outlook 2013 performs two independet 
autodiscover steps: It tries to discover a mobilesync setting, and it 
tries to discover a conventional Outlook setting as Outlook 2010 and 
Outlook 2007 do.

Some suggestions for Autodiscover.php:
- Line  113 and 136 check both for empty repsonse schema. this could 
be done directly after entering the _buildResponseString(..)  function 
to make the rest of the function easier to read.
- Line 135 opens a conditionalblock for the "autodiscover/outlook" 
schema, so within this block, it does not make sense to check for a 
mobilesync schema as done in lines 140:144. -> what was the intention 
of the line? In my opinion we must drop that lines, because the 
comparison in line 140 is always true and thus the function returns a 
failure response.

Bye the way:
the failure response has always  the response schema for a mobilesync, 
so RCA seems not to unterstand that an error occured. the 
_buildFailureResponse(..) function should use the correct response 
schema in line 216 to allow Outlook & RCA to unterstand that the error 
code is the response to teir query.

Torben
11/15/2012 02:00:02 PM Michael Rubinsky Comment #21 Reply to this comment

[Show Quoted Text - 14 lines]
Yeah, caught that last night and hadn't pushed it yet.  It's in Git now.
11/15/2012 12:00:06 PM torben (at) dannhauer (dot) info Comment #20 Reply to this comment

[Show Quoted Text - 17 lines]
Now I got the reason why it is not working:

around line 130, you test the responseschema to be empty.

This is not correct: for every autodiscover query the accetable 
response schema is delivered. Thus this variable should always be set, 
otherwise our parsing of the request is wrong.

Indeed, as I tested with outlook 2010 and also with the Microsoft 
"Remote Connectivity Analyzer" (         Connectivity Tests for Microsoft 
Office Outlook ), I discovered that with the RCA, the response schema 
is empty, because the string has different positions in Outlook and in 
RCA. This was new for me and was not adressed yet.

In my opinion we have to apply two changes to Autodiscover.php to get 
it working:
1. refactor line 130:135  to avoid 
"!empty($properties['response_schema'])" - which should never be 
emtpy.. As I said, I have no clue about the reason of this if-clause 
at lines 130:135
2. Make the repsonse schema more robust. It is not sufficient to 
extract values at certain place, but we have to parse for 
ACCEPTABLERESPONSESCHEMA to get the right value.

Please find below the request data send by RCA and by Outlook to get 
an idea how to fetch the response schema. this depub output is done by 
print:r() and thus represents the array structure

------------------------
values send by RCA:
     [0] => Array
         (
             [tag] => AUTODISCOVER
             [type] => open
             [level] => 1
             [attributes] => Array
                 (
                     [XMLNS:XSD] => http://www.w3.org/2001/XMLSchema
                     [XMLNS:XSI] => http://www.w3.org/2001/XMLSchema-instance
                     [XMLNS] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006
                 )

             [value] =>

         )

     [1] => Array
         (
             [tag] => REQUEST
             [type] => open
             [level] => 2
             [value] =>

         )

     [2] => Array
         (
             [tag] => EMAILADDRESS
             [type] => complete
             [level] => 3
             [value] => test2013@dannhauer.de
         )

     [3] => Array
         (
             [tag] => REQUEST
             [value] =>

             [type] => cdata
             [level] => 2
         )

     [4] => Array
         (
             [tag] => ACCEPTABLERESPONSESCHEMA
             [type] => complete
             [level] => 3
             [value] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a
         )

     [5] => Array
         (
             [tag] => REQUEST
             [value] =>

             [type] => cdata
             [level] => 2
         )

     [6] => Array
         (
             [tag] => REQUEST
             [type] => close
             [level] => 2
         )

     [7] => Array
         (
             [tag] => AUTODISCOVER
             [value] =>

             [type] => cdata
             [level] => 1
         )

     [8] => Array
         (
             [tag] => AUTODISCOVER
             [type] => close
             [level] => 1
         )
---------------------
values send by Outlook:
  [0] => Array
         (
             [tag] => AUTODISCOVER
             [type] => open
             [level] => 1
             [attributes] => Array
                 (
                     [XMLNS] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006
                 )

         )

     [1] => Array
         (
             [tag] => REQUEST
             [type] => open
             [level] => 2
         )

     [2] => Array
         (
             [tag] => EMAILADDRESS
             [type] => complete
             [level] => 3
             [value] => test2013@dannhauer.de
         )

     [3] => Array
         (
             [tag] => ACCEPTABLERESPONSESCHEMA
             [type] => complete
             [level] => 3
             [value] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a
         )

     [4] => Array
         (
             [tag] => REQUEST
             [type] => close
             [level] => 2
         )

     [5] => Array
         (
             [tag] => AUTODISCOVER
             [type] => close
             [level] => 1
         )

Thanks Torben
11/15/2012 11:25:16 AM torben (at) dannhauer (dot) info Comment #19 Reply to this comment
Implemented.

Anyway you can test the current Git code in your setup?
In autodiscover.php in line 66 is an error:

       if (!empty($results['raw_xml'])) {

should be

       if (empty($results['raw_xml'])) {

in my opinion. otherwise it wouldn't call buildResponse( if raw_xml is empty..

Torben
11/15/2012 10:37:12 AM torben (at) dannhauer (dot) info Comment #18 Reply to this comment

[Show Quoted Text - 17 lines]
Ah, I got it: I have overlooked the conf.xml, now I can configure all 
teh details in the settings tab.

I have some errors, it is currently not working but I assume it is my 
fault, so I'll dive into it tomorrow evening.

Torben
11/15/2012 08:10:04 AM torben (at) dannhauer (dot) info Comment #17 Reply to this comment

[Show Quoted Text - 9 lines]
Two question rise while reading the code:
- What is the intent of Audodiscover.php lines 130:135 ?
- How are the params of the outlook autodiscover set? Only via the 
hook or also via the actviesync configuration tab ? Just curious...

Torben

11/15/2012 07:18:46 AM torben (at) dannhauer (dot) info Comment #16 Reply to this comment
Implemented.

Anyway you can test the current Git code in your setup?
That was fast!
Of course I will test, but it may take some days, I'm not sure I can 
squeeze it in  today. I'll give you feedback till end of week at latest.
Torben
11/14/2012 10:25:03 PM Michael Rubinsky Comment #15
Assigned to Michael Rubinsky
Reply to this comment
Implemented.

Anyway you can test the current Git code in your setup?
11/14/2012 10:16:21 PM Git Commit Comment #14 Reply to this comment
Changes have been made in Git (master):

commit ba5b5d15d04bb3d490b5c3c5c3a522879b4ad730
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Wed Nov 14 16:36:03 2012 -0500

     Support sending Autodiscover responses for Outlook configuration.

     Part of Request: 11639

  .../lib/Horde/ActiveSync/Request/Autodiscover.php  |  100 
++++++++++++++++----
  1 files changed, 81 insertions(+), 19 deletions(-)

http://git.horde.org/horde-git/-/commit/ba5b5d15d04bb3d490b5c3c5c3a522879b4ad730
11/14/2012 10:16:15 PM Git Commit Comment #13 Reply to this comment
Changes have been made in Git (master):

commit df58e64aed4f1b600748fe3452d0363a753ba949
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Wed Nov 14 14:49:23 2012 -0500

     Add hooks for modifying autodiscover data and overriding the XML.

     Part of Request: 11639

  .../lib/Horde/ActiveSync/Request/Autodiscover.php  |   23 ++++++++++----
  .../Core/lib/Horde/Core/ActiveSync/Driver.php      |   30 +++++++++++++------
  horde/config/hooks.php.dist                        |   31 
+++++++++++++++++++-
  3 files changed, 67 insertions(+), 17 deletions(-)

http://git.horde.org/horde-git/-/commit/df58e64aed4f1b600748fe3452d0363a753ba949
11/14/2012 04:38:22 PM torben (at) dannhauer (dot) info Comment #12 Reply to this comment

[Show Quoted Text - 14 lines]
I agree, from my own mental roadman regarding AcrtieSync this does 
make sense, but not for the current implemntation status

Maybe you are right, step by step, first lets add the Outlook 
autodiscover support, later on the ActiveSync/Outlook support.

11/14/2012 03:10:45 PM Michael Rubinsky Comment #11 Reply to this comment
I discovered today, that Outlook 2013 performs two Autodiscover attempts:

The first is regarding IMAP/POP/SMTP, the second for ActiveSync.

In my opinion, Outlook 2013 should ignore the 
exchange/autodiscover/outlook query and should answer for the 
exchange/autodiscover/mobilesync query.
This doesn't make sense to me unless Horde actually supported EAS for 
Outlook 2013. Rather, once this is supported we should send a response 
based on the highest configured EAS version to support. For now, we 
should do the opposite; ignore the mobilesync request and only respond 
to the outlook request.

11/14/2012 07:44:32 AM steven (at) swartsit (dot) com Comment #10 Reply to this comment
Figured as much.

Cheers for letting me know. I'll keep watching for updates and give feedback.

Regards,
Steve

G'day Torben,

[Show Quoted Text - 24 lines]
11/14/2012 07:42:27 AM torben (at) dannhauer (dot) info Comment #9 Reply to this comment

[Show Quoted Text - 15 lines]
G'day,

my Funambol experience is quite bad, so I will never use funambol again.

No, with Outlook 2010 there is now way to use Horde's ActiveSync 
capabilities. You would need a newer version of Outlook (2013) and 
Horde EAS implementation (14).

Torben
11/14/2012 07:36:51 AM steven (at) swartsit (dot) com Comment #8 Reply to this comment
G'day Torben,

Thanks for the update, very helpful.

So there is no way currently for Horde with its Activesync Mobile 
ability to communicate with Outlook 2010 - Funambol doesn't work in my 
experience with Windows 8.

I would gladly help, however my expertise are quite limited. I have a 
background only in network administration. So unfortunately I cannot 
help. But I would be glad to help out in any other way, for example 
testing, etc.

Regards,
Steve
11/14/2012 07:21:25 AM torben (at) dannhauer (dot) info Comment #7 Reply to this comment
Will this allow Outlook to be configured for Exchange setup?
Syncing Email, Calendar, Contacts?

Top job though mate, thumbs up from Aus.
It depends on your outlook version.Outlook 2007 and 2010 support only 
true exchange (which horde does NOT) and of course IMAP and POP. This 
modification adds autodiscover for Outlook to use IMAP if available, 
otherwise POP.

In addition, Outlook 2013 supports native "Exchange ActiveSync" (EAS) 
connections, it is able to act as an active sync client like a 
smortphone does. This includes email, contancts, calendars and tasks.
The autodiscover service of Outlook 2013 is performed in two stages: 
it queries the existing mobilesync response schema to get an EAS 
setup. Additionaly it queries the classical exchange schema I proposed 
in this ticket to autodiscover the SMTP/POP/IMAP setup.
Native ActiveSync usage of Outlook 2013 works regarding the 
autodiscover feature, but unfortunately Outlook requieres EAS version 
14.x, and horde only provides version 12.1. This is the show stopper 
for Outtlook 2013+Horde currently.

According to micheal they requiere round about 40 hours to implement 
EAS version 14.
I'm willing to spend a part of the necessary hours to Horde LLC. Maybe 
you are one of these to spend the other hours.. :)

By the way: tine2.0 has oldready implemented a update to work with 
Outlook 2013 ( currently not released, only in their GIT repo), so it 
should also be possible for Horde

Best wishes,
Torben


11/14/2012 05:07:48 AM steven (at) swartsit (dot) com Comment #6 Reply to this comment
Will this allow Outlook to be configured for Exchange setup?
Syncing Email, Calendar, Contacts?

Top job though mate, thumbs up from Aus.
11/12/2012 07:20:30 PM torben (at) dannhauer (dot) info Comment #5 Reply to this comment
I discovered today, that Outlook 2013 performs two Autodiscover attempts:

The first is regarding IMAP/POP/SMTP, the second for ActiveSync.

In my opinion, Outlook 2013 should ignore the 
exchange/autodiscover/outlook query and should answer for the 
exchange/autodiscover/mobilesync query.

this is the query debug output of the two Outlook requests:

[12-Nov-2012 19:05:27] _buildResponseString properties as struct: Array
(
     [display_name] =>
     [email] => test@osgvisual.org
     [url] => https://www.dannhauer.de/Microsoft-Server-ActiveSync
     [culture] => en:en
     [request_schema] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006
     [response_schema] => 
http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a
)
[12-Nov-2012 19:05:27] _buildResponseString user_agent: Microsoft 
Office/15.0 (Windows NT 6.1; Microsoft Outlook 15.0.4128; Pro)


[12-Nov-2012 19:05:28] _buildResponseString properties as struct: Array
(
     [display_name] =>
     [email] => test@osgvisual.org
     [url] => https://www.dannhauer.de/Microsoft-Server-ActiveSync
     [culture] => en:en
     [request_schema] => 
http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006
     [response_schema] => 
http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006
)
[12-Nov-2012 19:05:28] _buildResponseString user_agent: Microsoft.Outlook.15


11/06/2012 12:23:05 AM torben (at) dannhauer (dot) info Comment #4
New Attachment: Autodiscover.php.diff Download
Reply to this comment
*Please* provide standard diffs/patches.
Here is a diff, I hope it is the right format:

Thanks,
Torben


11/05/2012 11:36:17 AM torben (at) dannhauer (dot) info Comment #3 Reply to this comment
sorry, each project has other rules, I was not aware of the horde 
submission protocol.

I will create diffs this evening and attach it as soon as possible.
11/05/2012 11:31:17 AM Jan Schneider State ⇒ Feedback
 
11/04/2012 05:47:19 PM Michael Rubinsky Comment #2
Priority ⇒ 1. Low
Version ⇒ Git develop
Reply to this comment
*Please* provide standard diffs/patches.
11/04/2012 05:20:29 PM torben (at) dannhauer (dot) info Comment #1
Priority ⇒ 3. High
State ⇒ New
Patch ⇒ Yes
Milestone ⇒
Summary ⇒ ActiveSync :: Extend the Autodiscover feature to return also valid answers to MS Outlook queries
Type ⇒ Enhancement
Queue ⇒ Horde Framework Packages
Reply to this comment
The AutoDiscover feature could be enhanced to answer also queries 
performed  by Microsoft Outlook Mail clients.

Mail clients like Outlook 2010 and older should auto discover there 
IMAP/SMTP settings, Outlook 2013 clients could be handled seperately 
to allow ActiveSync connections once EAS Protocoll 14.1 or above is 
implemented in Horde.

This Ticket relies an the implementation submitted in Horde Ticket 
11637 (http://bugs.horde.org/ticket/11637) to be able to analyze he 
request schema.

Please edit Horde/ActiveSync/Request/Autodiscover.php and enhance the 
function "_buildResponseString($properties)" to:


    protected function _buildResponseString($properties)
     {
         if (stripos($properties['request_schema'], 
'autodiscover/mobilesync') !== false) {
             return '<?xml version="1.0" encoding="utf-8"?>
               <Autodiscover 
xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
                 <Response 
xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006">
                   <Culture>' . $properties['culture'] . '</Culture>
                   <User>
                     <DisplayName>' . $properties['display_name'] . 
'</DisplayName>
                     <EMailAddress>' . $properties['email'] . '</EMailAddress>
                   </User>
                   <Action>
                     <Settings>
                       <Server>
                         <Type>MobileSync</Type>
                          <Url>' . $properties['url'] . '</Url>
                          <Name>' . $properties['url'] . '</Name>
                        </Server>
                     </Settings>
                   </Action>
                 </Response>
               </Autodiscover>';
         }
         else if (stripos($properties['request_schema'], 
'autodiscover/outlook') !== false) {
             //// MS Outlook 2013 (Outlook 15) : Output data for ActiveSync
             //if(preg_match("Microsoft[\.|\s]Outlook[\.|\s]15", 
$_SERVER['HTTP_USER_AGENT'])) {
                // Todo: currently not supported by horde because 
Outlook 2013 ActiveSync requires EAS Protocol 14.1 or above
            //}
           // Any other MS Outlook version: Output data for IMAP
           if (stripos( $_SERVER['HTTP_USER_AGENT'], 'Outlook') !== false) {
             return '<Autodiscover 
xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
               <Response xmlns="' . $properties['response_schema'] . '">
                 <User>
                   <DisplayName>' . $properties['display_name'] . 
'</DisplayName>
                 </User>
                 <Account>
                   <AccountType>email</AccountType>
                     <Action>settings</Action>
                       <Protocol>
                         <Type>IMAP</Type>
                         <Server>my-horde.tld</Server>
                         <Port>993</Port>
                         <LoginName>' . $properties['email'] . '</LoginName>
                         <DomainRequired>off</DomainRequired>
                         <SPA>off</SPA>
                         <SSL>on</SSL>
                         <AuthRequired>on</AuthRequired>
                       </Protocol>
                       <Protocol>
                         <Type>POP3</Type>
                         <Server>my-horde.tld</Server>
                         <Port>110</Port>
                         <LoginName>' . $properties['email'] . '</LoginName>
                         <DomainRequired>off</DomainRequired>
                         <SPA>off</SPA>
                         <SSL>on</SSL>
                         <AuthRequired>on</AuthRequired>
                       </Protocol>
                       <Protocol>
                         <Type>SMTP</Type>
                         <Server>my-horde.tld</Server>
                         <Port>465</Port>
                         <LoginName>' . $properties['email'] . '</LoginName>
                         <DomainRequired>off</DomainRequired>
                         <SPA>off</SPA>
                         <SSL>on</SSL>
                         <AuthRequired>on</AuthRequired>
                         <UsePOPAuth>on</UsePOPAuth>
                       </Protocol>
                    </Account>
                 </Response>
              </Autodiscover>';
         }
     }
     else    return(_buildFailureResponse($properties['email'], 
"Invalid autodiscover schema")); // Fallback
}

Please  be aware that this example has hardcoded values in the outlook 
response. It should be configurable in the Administration/ActiveSync 
prefs.
The following aspects should be configurable:
* Which protocol types should be configured for autodetection (IMAP, 
POP3, SMTP
* The server for each protocol type
* The Port for each protocol type
* If SSL is active for each protocol type
* If SMTP requires Pop-auth

This example with hardcode values is tested and works with MS Outlook 2010.
The ActiveSync profile for MS Outlook 2013 cannot be testet because 
Horde needs to implement EAS protocol 14 to allow MS Outlook  2013 to 
be used as ActiveSync client.

Many Thanks,
Torben Dannhauer


Saved Queries