diff --git a/docs/README b/docs/README --- a/docs/README +++ b/docs/README @@ -23,12 +23,12 @@ 1. Apache # for https://domain.tld (and https://autodiscover.domain.tld) -Alias /autodiscover/autodiscover.xml /usr/share/kolab-autodiscover/public_html -Alias /Autodiscover/Autodiscover.xml /usr/share/kolab-autodiscover/public_html -Alias /AutoDiscover/AutoDiscover.xml /usr/share/kolab-autodiscover/public_html +Alias /autodiscover/autodiscover.xml /usr/share/kolab-autoconf/public_html/index.php +Alias /Autodiscover/Autodiscover.xml /usr/share/kolab-autoconf/public_html/index.php +Alias /AutoDiscover/AutoDiscover.xml /usr/share/kolab-autoconf/public_html/index.php # for http://autoconfig.domain.tld -Alias /mail/config-v1.1.xml /usr/share/kolab-autodiscover/public_html -# for http://domain.tld -Alias /.well-known/autoconfig/mail/config-v1.1.xml /usr/share/kolab-autodiscover/public_html +Alias /mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html/index.php +# for http://domain.tld/index.php +Alias /.well-known/autoconfig/mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html/index.php 2. Add [autodiscover] section in /etc/kolab/kolab.conf (see sample kolab.conf.sample) diff --git a/docs/kolab-autoconf.conf b/docs/kolab-autoconf.conf --- a/docs/kolab-autoconf.conf +++ b/docs/kolab-autoconf.conf @@ -1,11 +1,11 @@ # for https://domain.tld (and https://autodiscover.domain.tld) -Alias /autodiscover/autodiscover.xml /usr/share/kolab-autoconf/public_html -Alias /Autodiscover/Autodiscover.xml /usr/share/kolab-autoconf/public_html -Alias /AutoDiscover/AutoDiscover.xml /usr/share/kolab-autoconf/public_html +Alias /autodiscover/autodiscover.xml /usr/share/kolab-autoconf/public_html/index.php +Alias /Autodiscover/Autodiscover.xml /usr/share/kolab-autoconf/public_html/index.php +Alias /AutoDiscover/AutoDiscover.xml /usr/share/kolab-autoconf/public_html/index.php # for http://autoconfig.domain.tld -Alias /mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html +Alias /mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html/index.php # for http://domain.tld -Alias /.well-known/autoconfig/mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html +Alias /.well-known/autoconfig/mail/config-v1.1.xml /usr/share/kolab-autoconf/public_html/index.php AllowOverride None diff --git a/lib/AutodiscoverMicrosoft.php b/lib/AutodiscoverMicrosoft.php --- a/lib/AutodiscoverMicrosoft.php +++ b/lib/AutodiscoverMicrosoft.php @@ -53,11 +53,24 @@ try { $xml = new SimpleXMLElement($post); - if ($email = $xml->xpath('/Autodiscover/Request/EMailAddress')) { + $namespaces = $xml->getNamespaces(true); + if(isset($namespaces[""])) { // if you have a default namespace + // register a prefix for that default namespace: + $xml->registerXPathNamespace("default", $namespaces[""]); + // and use that prefix in all of your xpath expressions: + $xpath = "/default:"; + Log::debug('namespace [default]: ' . $namespaces[""]); + } else { + $xpath = ""; + } + + if ($email = $xml->xpath('/' . $xpath . 'Autodiscover/' . $xpath . 'Request/' . $xpath . 'EMailAddress')) { + Log::debug('Request [EMailAddress]: ' . $email); $this->email = (string) array_shift($email); } - if ($schema = $xml->xpath('/Autodiscover/Request/AcceptableResponseSchema')) { + if ($schema = $xml->xpath('/' . $xpath . 'Autodiscover/' . $xpath . 'Request/' . $xpath . 'AcceptableResponseSchema')) { + Log::debug('Request [AcceptableResponseSchema]: ' . $schema); $schema = (string) array_shift($schema); if (strpos($schema, 'mobilesync')) { @@ -105,10 +118,10 @@ $xml = new DOMDocument('1.0', Autodiscover::CHARSET); // create main elements (tree) - $doc = $xml->createElementNS(self::MOBILESYNC_NS, 'Autodiscover'); + $doc = $xml->createElementNS(self::NS, 'Autodiscover'); $doc = $xml->appendChild($doc); - $response = $xml->createElement('Response'); + $response = $xml->createElementNS(self::MOBILESYNC_NS, 'Response'); $response = $doc->appendChild($response); $user = $xml->createElement('User'); @@ -124,14 +137,14 @@ $server = $settings->appendChild($server); // configuration -/* + $dispname = $xml->createElement('DisplayName'); $dispname = $user->appendChild($dispname); - $dispname->appendChild($xml->createTextNode($this->config['user'])); -*/ + $dispname->appendChild($xml->createTextNode($this->config['username'])); + $email = $xml->createElement('EMailAddress'); $email = $user->appendChild($email); - $email->appendChild($xml->createTextNode($this->config['email'])); + $email->appendChild($xml->createTextNode($this->config['login'] ?: $this->config['email'])); $element = $xml->createElement('Type'); $element = $server->appendChild($element);