/** * @param string $name * @param string $password * @return bool */ public function areCredentialsValid($name, $password) { $name = $this->DNasBaseParameter($name); $testConnection = clone $this->connection; $credentials = array('ldapAgentName' => $name, 'ldapAgentPassword' => $password); if (!$testConnection->setConfiguration($credentials)) { return false; } $result = $testConnection->bind(); $this->connection->bind(); return $result; }
/** * tests the specified connection * @param string $configID * @return int */ protected function testConfig($configID) { $lw = new \OCA\user_ldap\lib\LDAP(); $connection = new Connection($lw, $configID); //ensure validation is run before we attempt the bind $connection->getConfiguration(); if (!$connection->setConfiguration(array('ldap_configuration_active' => 1))) { return 1; } if ($connection->bind()) { return 0; } return 2; }