/** * Suggest settings based on the underlying discovery * * @param bool $suppressArrayNotation * * @return array|null */ public function getValues($suppressArrayNotation = false) { if (!isset($this->discovery) || !$this->discovery->isSuccess()) { return null; } $disc = $this->discovery; return array('domain' => $this->getValue('domain'), 'type' => $disc->isAd() ? LdapDiscoveryConfirmPage::TYPE_AD : LdapDiscoveryConfirmPage::TYPE_MISC, 'resource' => $disc->suggestResourceSettings(), 'backend' => $disc->suggestBackendSettings()); }
/** * Discover LDAP servers on the given domain * * @param string $domain The object containing the form elements * * @return Discovery True when the discovery was successful, false when the configuration was guessed */ public static function discoverDomain($domain) { if (!isset($domain)) { return false; } // Attempt 1: Connect to the domain directly $disc = Discovery::discover($domain, 389); if ($disc->isSuccess()) { return $disc; } // Attempt 2: Discover all available ldap dns records and connect to the first one $records = array_merge(Dns::getSrvRecords($domain, 'ldap'), Dns::getSrvRecords($domain, 'ldaps')); if (isset($records[0])) { $record = $records[0]; return Discovery::discover(isset($record['target']) ? $record['target'] : $domain, isset($record['port']) ? $record['port'] : $domain); } // Return the first failed discovery, which will suggest properties based on guesses return $disc; }