/** * Binds to the current connection using the * inserted credentials. * * @param string $username * @param string $password * * @returns bool * * @throws AdldapException */ protected function bindUsingCredentials($username, $password) { if (empty($username)) { // Allow binding with null username. $username = null; } else { // If the username isn't empty, we'll append the configured // account suffix to bind to the LDAP server. $username .= $this->configuration->getAccountSuffix(); } if (empty($password)) { // Allow binding with null password $password = null; } if ($this->connection->bind($username, $password) === false) { $error = $this->connection->getLastError(); if ($this->connection->isUsingSSL() && $this->connection->isUsingTLS() === false) { $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: ' . $error; } else { $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: ' . $error; } throw new AdldapException($message); } return true; }
/** * Binds to the current connection using the * inserted credentials. * * @param string $username * @param string $password * * @returns bool * * @throws AdldapException */ private function bindUsingCredentials($username, $password) { // Allow binding with null credentials if (empty($username)) { $username = null; } else { $username .= $this->configuration->getAccountSuffix(); } if (empty($password)) { $password = null; } if (!$this->connection->bind($username, $password)) { $error = $this->connection->getLastError(); if ($this->connection->isUsingSSL() && !$this->connection->isUsingTLS()) { $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: ' . $error; } else { $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: ' . $error; } throw new AdldapException($message); } return true; }