/** * * Verifies a set of credentials. * * @param array $input An array of credential data, including any data to * bind to the query. * * @return array An array of login data. * * @throws Exception\ConnectionFailed when the IMAP connection fails. * */ public function login(array $input) { $this->checkInput($input); $username = $input['username']; $password = $input['password']; $conn = $this->phpfunc->imap_open($this->mailbox, $username, $password, $this->options, $this->retries, $this->params); if (!$conn) { throw new Exception\ConnectionFailed($this->mailbox); } $this->phpfunc->imap_close($conn); return array($username, array()); }
/** * * Binds to the LDAP server with username and password. * * @param resource $conn The LDAP connection. * * @param string $username The input username. * * @param string $password The input password. * * @throws Exception\BindFailed when the username/password fails. * */ protected function bind($conn, $username, $password) { $username = $this->escape($username); $bind_rdn = sprintf($this->dnformat, $username); $bound = $this->phpfunc->ldap_bind($conn, $bind_rdn, $password); if (!$bound) { $error = $this->phpfunc->ldap_errno($conn) . ': ' . $this->phpfunc->ldap_error($conn); $this->phpfunc->ldap_close($conn); throw new Exception\BindFailed($error); } $this->phpfunc->ldap_unbind($conn); $this->phpfunc->ldap_close($conn); }