Changeset View
Changeset View
Standalone View
Standalone View
lib/AutodiscoverMicrosoft.php
Show All 27 Lines | |||||
*/ | */ | ||||
class AutodiscoverMicrosoft extends Autodiscover | class AutodiscoverMicrosoft extends Autodiscover | ||||
{ | { | ||||
const NS = "http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006"; | const NS = "http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006"; | ||||
const RESPONSE_NS = "http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"; | const RESPONSE_NS = "http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"; | ||||
const MOBILESYNC_NS = "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006"; | const MOBILESYNC_NS = "http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006"; | ||||
private $type = 'outlook'; | private $type = 'outlook'; | ||||
private $password; | |||||
/** | /** | ||||
* Handle request parameters (find email address) | * Handle request parameters (find email address) | ||||
*/ | */ | ||||
protected function handle_request() | protected function handle_request() | ||||
{ | { | ||||
$post = $_SERVER['REQUEST_METHOD'] == 'POST' ? file_get_contents('php://input') : null; | $post = $_SERVER['REQUEST_METHOD'] == 'POST' ? file_get_contents('php://input') : null; | ||||
Log::debug('Request [microsoft]: ' . $post); | // check for basic authentication | ||||
Log::debug('Request [microsoft]: Basic Auth Username: ' . ($_SERVER['PHP_AUTH_USER'] ?: 'none')); | |||||
if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) { | |||||
$this->unauthorized(); | |||||
} | |||||
$this->password = $_SERVER['PHP_AUTH_PW']; | |||||
// check for request object | |||||
Log::debug('Request [microsoft]: ' . $post); | |||||
if (empty($post)) { | if (empty($post)) { | ||||
$this->error("Invalid input"); | $this->error("Invalid input"); | ||||
} | } | ||||
// parse XML | // parse XML | ||||
try { | try { | ||||
$xml = new SimpleXMLElement($post); | $xml = new SimpleXMLElement($post); | ||||
$ns = $xml->getDocNamespaces(); | $ns = $xml->getDocNamespaces(); | ||||
Show All 14 Lines | protected function handle_request() | ||||
if (strpos($schema, 'mobilesync')) { | if (strpos($schema, 'mobilesync')) { | ||||
$this->type = 'mobilesync'; | $this->type = 'mobilesync'; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
catch (Exception $e) { | catch (Exception $e) { | ||||
$this->error("Invalid input"); | $this->error("Invalid input"); | ||||
} | } | ||||
// basic auth username must match with given email address | |||||
if ($_SERVER['PHP_AUTH_USER'] != $this->email) { | |||||
$this->unauthorized(); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Handle response | * Handle response | ||||
*/ | */ | ||||
public function handle_response() | public function handle_response() | ||||
{ | { | ||||
$method = $this->type . '_response'; | // authenticate the user found during configure() against ldap | ||||
if (empty($this->config['dn']) || !$this->authenticate($this->config['dn'], $this->password)) { | |||||
$this->unauthorized(); | |||||
} | |||||
$method = $this->type . '_response'; | |||||
$xml = $this->$method(); | $xml = $this->$method(); | ||||
$xml->formatOutput = true; | $xml->formatOutput = true; | ||||
$response = $xml->saveXML(); | $response = $xml->saveXML(); | ||||
Log::debug('Response [microsoft]: ' . $response); | Log::debug('Response [microsoft]: ' . $response); | ||||
header('Content-type: text/xml; charset=' . Autodiscover::CHARSET); | header('Content-type: text/xml; charset=' . Autodiscover::CHARSET); | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |