Changeset View
Changeset View
Standalone View
Standalone View
lib/AutodiscoverMicrosoft.php
Show All 36 Lines | class AutodiscoverMicrosoft extends Autodiscover | ||||
/** | /** | ||||
* 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; | ||||
// 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 | // check for request object | ||||
Log::debug('Request [microsoft]: ' . $post); | 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 { | ||||
Show All 17 Lines | protected function handle_request() | ||||
$this->type = 'mobilesync'; | $this->type = 'mobilesync'; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
catch (Exception $e) { | catch (Exception $e) { | ||||
$this->error("Invalid input"); | $this->error("Invalid input"); | ||||
} | } | ||||
// check for basic authentication if ldap is available | |||||
if (!empty($this->_ldap_server)) { | |||||
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(); | |||||
} | |||||
// basic auth username must match with given email address | // basic auth username must match with given email address | ||||
if ($_SERVER['PHP_AUTH_USER'] != $this->email) { | if ($_SERVER['PHP_AUTH_USER'] != $this->email) { | ||||
$this->unauthorized(); | $this->unauthorized(); | ||||
} | } | ||||
$this->password = $_SERVER['PHP_AUTH_PW']; | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Handle response | * Handle response | ||||
*/ | */ | ||||
public function handle_response() | public function handle_response() | ||||
{ | { | ||||
if (!empty($this->_ldap_server)) { | |||||
// authenticate the user found during configure() against ldap | // authenticate the user found during configure() against ldap | ||||
if (empty($this->config['dn']) || !$this->authenticate($this->config['dn'], $this->password)) { | if (empty($this->config['dn']) || !$this->authenticate($this->config['dn'], $this->password)) { | ||||
$this->unauthorized(); | $this->unauthorized(); | ||||
} | } | ||||
} | |||||
$method = $this->type . '_response'; | $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); | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |