/** * * Connects to the LDAP server and sets options. * * @return resource The LDAP connection. * * @throws Exception\ConnectionFailed when the connection fails. * */ protected function connect() { $conn = $this->phpfunc->ldap_connect($this->server); if (!$conn) { throw new Exception\ConnectionFailed($this->server); } foreach ($this->options as $opt => $val) { $this->phpfunc->ldap_set_option($conn, $opt, $val); } return $conn; }