/** * {@inheritdoc} */ public function bindAsAdministrator() { $username = $this->configuration->getAdminUsername(); $password = $this->configuration->getAdminPassword(); $suffix = $this->configuration->getAdminAccountSuffix(); $this->bindUsingCredentials($username, $password, $suffix); }
/** * Binds to the LDAP server as the configured administrator. * * @throws AdldapException */ protected function bindAsAdministrator() { $adminUsername = $this->configuration->getAdminUsername(); $adminPassword = $this->configuration->getAdminPassword(); $this->bindUsingCredentials($adminUsername, $adminPassword); if ($this->connection->isBound() === false) { $error = $this->connection->getLastError(); throw new AdldapException("Rebind to Active Directory failed. AD said: {$error}"); } }
/** * {@inheritdoc} */ public function bindAsAdministrator() { $username = $this->configuration->getAdminUsername(); $password = $this->configuration->getAdminPassword(); $suffix = $this->configuration->getAdminAccountSuffix(); if (empty($suffix)) { // Use the user account suffix if no administrator account suffix is given. $suffix = $this->configuration->getAccountSuffix(); } $this->bindUsingCredentials($username, $password, $suffix); }
/** * Prepares the connection by setting configured parameters. * * @return void */ protected function prepareConnection() { // Set the beginning protocol options on the connection // if they're set in the configuration. if ($this->configuration->getUseSSL()) { $this->connection->useSSL(); } elseif ($this->configuration->getUseTLS()) { $this->connection->useTLS(); } // If we've set SSO to true, we'll make sure we check if // SSO is supported, and if so we'll bind it to // the current LDAP connection. if ($this->configuration->getUseSSO() && $this->connection->isSaslSupported()) { $this->connection->useSSO(); } }
/** * Binds to the LDAP server as the configured administrator. * * @throws AdldapException * * @return bool */ protected function bindAsAdministrator() { $adminUsername = $this->configuration->getAdminUsername(); $adminPassword = $this->configuration->getAdminPassword(); $adminSuffix = $this->configuration->getAdminAccountSuffix(); if (empty($adminSuffix)) { // If the admin suffix is empty, we'll use the default account suffix. $adminSuffix = $this->configuration->getAccountSuffix(); } $this->bindUsingCredentials($adminUsername, $adminPassword, $adminSuffix); if ($this->connection->isBound() === false) { $error = $this->connection->getLastError(); throw new AdldapException("Rebind to Active Directory failed. AD said: {$error}"); } 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; }
/** * {@inheritdoc} */ public function bindAsAdministrator() { $adminUsername = $this->configuration->getAdminUsername(); $adminPassword = $this->configuration->getAdminPassword(); $this->bindUsingCredentials($adminUsername, $adminPassword); }