*/ private array $config; /** * @param array $ldapConfig */ public function __construct(array $ldapConfig) { $this->config = $ldapConfig; } /** * Erstellt eine LDAP-Verbindung mit gesetzten Optionen (Protokollversion, Timeout), * aber ohne Bind. Den Bind führen die aufrufenden Services durch. * * @return resource LDAP-Verbindungs-Handle */ public function createConnection() { $server = (string)($this->config['server'] ?? ''); $port = (int)($this->config['port'] ?? 636); $timeout = (int)($this->config['timeout'] ?? 5); if ($server === '') { throw new RuntimeException('LDAP-Konfiguration ist unvollständig (server fehlt).'); } $connection = ldap_connect($server, $port); if ($connection === false) { throw new RuntimeException('LDAP-Verbindung konnte nicht aufgebaut werden.'); } ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($connection, LDAP_OPT_NETWORK_TIMEOUT, $timeout); return $connection; } }