Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2484903
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/docs/README b/docs/README
index 708a12f..112f69b 100644
--- a/docs/README
+++ b/docs/README
@@ -1,34 +1,34 @@
INTO
----
Autodiscover service implements automatic account configuration for email
and ActiveSync clients.
* Outlook
http://msdn.microsoft.com/en-us/library/cc463896%28v=exchg.80%29.aspx
* Activesync
http://msdn.microsoft.com/en-us/library/ee200809%28v=exchg.80%29.aspx
* Mozilla (Evolution/KMail/Kontact)
https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration
CONFIGURATION
-------------
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
index ca59ef9..5f8a1fd 100644
--- a/docs/kolab-autoconf.conf
+++ b/docs/kolab-autoconf.conf
@@ -1,19 +1,19 @@
# 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
<Directory "/usr/share/kolab-autoconf/public_html">
AllowOverride None
<ifModule mod_authz_core.c>
Require all granted
</ifModule>
<ifModule !mod_authz_core.c>
Order Allow,Deny
Allow from All
</ifModule>
</Directory>
diff --git a/lib/AutodiscoverMicrosoft.php b/lib/AutodiscoverMicrosoft.php
index a067b2c..4a3e2db 100644
--- a/lib/AutodiscoverMicrosoft.php
+++ b/lib/AutodiscoverMicrosoft.php
@@ -1,246 +1,246 @@
<?php
/**
+--------------------------------------------------------------------------+
| Kolab Autodiscover Service |
| |
| Copyright (C) 2011-2014, Kolab Systems AG <contact@kolabsys.com> |
| |
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation, either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program. If not, see http://www.gnu.org/licenses/. |
+--------------------------------------------------------------------------+
| Author: Aleksander Machniak <machniak@kolabsys.com> |
+--------------------------------------------------------------------------+
*/
/**
* Autodiscover Service class for Microsoft Outlook and Activesync devices
*/
class AutodiscoverMicrosoft extends Autodiscover
{
const NS = "http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006";
const RESPONSE_NS = "http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a";
const MOBILESYNC_NS = "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006";
private $type = 'outlook';
/**
* Handle request parameters (find email address)
*/
protected function handle_request()
{
$post = $_SERVER['REQUEST_METHOD'] == 'POST' ? file_get_contents('php://input') : null;
Log::debug('Request [microsoft]: ' . $post);
if (empty($post)) {
$this->error("Invalid input");
}
// parse XML
try {
$xml = new SimpleXMLElement($post);
$ns = $xml->getDocNamespaces();
if (empty($ns) || empty($ns[''])) {
$this->error("Invalid input. Missing XML request schema");
}
$xml->registerXPathNamespace('request', $ns['']);
if ($email = $xml->xpath('//request:EMailAddress')) {
$this->email = (string) array_shift($email);
}
if ($schema = $xml->xpath('//request:AcceptableResponseSchema')) {
$schema = (string) array_shift($schema);
if (strpos($schema, 'mobilesync')) {
$this->type = 'mobilesync';
}
}
}
catch (Exception $e) {
$this->error("Invalid input");
}
}
/**
* Handle response
*/
public function handle_response()
{
$method = $this->type . '_response';
$xml = $this->$method();
$xml->formatOutput = true;
$response = $xml->saveXML();
Log::debug('Response [microsoft]: ' . $response);
header('Content-type: text/xml; charset=' . Autodiscover::CHARSET);
echo $response;
exit;
}
/**
* Generates XML response for Activesync
*/
protected function mobilesync_response()
{
if (empty($this->config['activesync'])) {
$this->error("Activesync not supported");
}
if (!preg_match('/^https?:/i', $this->config['activesync'])) {
$this->config['activesync'] = 'https://' . $this->config['activesync'] . '/Microsoft-Server-ActiveSync';
}
$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');
$user = $response->appendChild($user);
$action = $xml->createElement('Action');
$action = $response->appendChild($action);
$settings = $xml->createElement('Settings');
$settings = $action->appendChild($settings);
$server = $xml->createElement('Server');
$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);
$element->appendChild($xml->createTextNode('MobileSync'));
$element = $xml->createElement('Url');
$element = $server->appendChild($element);
$element->appendChild($xml->createTextNode($this->config['activesync']));
$element = $xml->createElement('Name');
$element = $server->appendChild($element);
$element->appendChild($xml->createTextNode($this->config['activesync']));
return $xml;
}
/**
* Generates XML response for Outlook
*/
protected function outlook_response()
{
$xml = new DOMDocument('1.0', Autodiscover::CHARSET);
// create main elements (tree)
$doc = $xml->createElementNS(self::NS, 'Autodiscover');
$doc = $xml->appendChild($doc);
$response = $xml->createElementNS(self::RESPONSE_NS, 'Response');
$response = $doc->appendChild($response);
$user = $xml->createElement('User');
$user = $response->appendChild($user);
$account = $xml->createElement('Account');
$account = $response->appendChild($account);
$accountType = $xml->createElement('AccountType');
$accountType = $account->appendChild($accountType);
$accountType->appendChild($xml->createTextNode('email'));
$action = $xml->createElement('Action');
$action = $account->appendChild($action);
$action->appendChild($xml->createTextNode('settings'));
// 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('AutoDiscoverSMTPAddress');
$email = $user->appendChild($email);
$email->appendChild($xml->createTextNode($this->config['email']));
// @TODO: Microsoft supports also DAV protocol here
foreach (array('imap', 'pop3', 'smtp') as $type) {
if (!empty($this->config[$type])) {
$protocol = $this->add_protocol_element($xml, $type, $this->config[$type]);
$account->appendChild($protocol);
}
}
return $xml;
}
/**
* Creates Protocol element for XML response
*/
private function add_protocol_element($xml, $type, $config)
{
$protocol = $xml->createElement('Protocol');
$element = $xml->createElement('Type');
$element = $protocol->appendChild($element);
$element->appendChild($xml->createTextNode(strtoupper($type)));
// @TODO: TTL/ExpirationDate tags
// server attributes map
$server_attributes = array(
'Server' => 'hostname',
'Port' => 'port',
'LoginName' => 'username',
);
foreach ($server_attributes as $tag_name => $conf_name) {
$value = $this->config[$type][$conf_name];
if (!empty($value)) {
$element = $xml->createElement($tag_name);
$element->appendChild($xml->createTextNode($value));
$protocol->appendChild($element);
}
}
$spa = $this->config[$type]['authentication'] == 'password-encrypted' ? 'on' : 'off';
$element = $xml->createElement('SPA');
$element->appendChild($xml->createTextNode($spa));
$protocol->appendChild($element);
$map = array('STARTTLS' => 'TLS', 'SSL' => 'SSL', 'plain' => 'None');
$element = $xml->createElement('Encryption');
$element->appendChild($xml->createTextNode($map[$this->config[$type]['socketType']] ?: 'Auto'));
$protocol->appendChild($element);
return $protocol;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 20, 12:44 PM (11 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387155
Default Alt Text
(12 KB)
Attached To
Mode
R9 autoconf
Attached
Detach File
Event Timeline
Log In to Comment