예제 #1
0
 public function Validate($username, $password)
 {
     if ($this->AreCredentialsKnown()) {
         $username = ServiceLocator::GetServer()->GetHeader('AUTH_USER');
         $username = $this->CleanUsername($username);
         Log::Debug('ActiveDirectory Validate trying to load details for authenticated user: %s', $username);
         $this->ldap->Connect();
         $this->user = $this->ldap->GetLdapUser($username);
         return $this->LdapUserExists();
     }
     $this->password = $password;
     $username = $this->CleanUsername($username);
     $connected = $this->ldap->Connect();
     if (!$connected) {
         throw new Exception('Could not connect to ActiveDirectory LDAP server. Please check your ActiveDirectory LDAP configuration settings');
     }
     $isValid = $this->ldap->Authenticate($username, $password);
     Log::Debug('Result of ActiveDirectory LDAP Authenticate for user %s: %d', $username, $isValid);
     if ($isValid) {
         $this->user = $this->ldap->GetLdapUser($username);
         $userLoaded = $this->LdapUserExists();
         if (!$userLoaded) {
             Log::Error('Could not load user details from ActiveDirectory LDAP. Check your basedn setting. User: %s', $username);
         }
         return $userLoaded;
     } else {
         if ($this->options->RetryAgainstDatabase()) {
             return $this->authToDecorate->Validate($username, $password);
         }
     }
     return false;
 }
예제 #2
0
파일: Ldap.php 프로젝트: hugutux/booked
 public function Validate($username, $password)
 {
     $this->password = $password;
     $username = $this->CleanUsername($username);
     $connected = $this->ldap->Connect();
     if (!$connected) {
         throw new Exception("Could not connect to LDAP server. Please check your LDAP configuration settings");
     }
     $filter = $this->options->Filter();
     $isValid = $this->ldap->Authenticate($username, $password, $filter);
     Log::Debug("Result of LDAP Authenticate for user %s: %d", $username, $isValid);
     if ($isValid) {
         $this->user = $this->ldap->GetLdapUser($username);
         $userLoaded = $this->LdapUserExists();
         if (!$userLoaded) {
             Log::Error("Could not load user details from LDAP. Check your ldap settings. User: %s", $username);
         }
         return $userLoaded;
     } else {
         if ($this->options->RetryAgainstDatabase()) {
             return $this->authToDecorate->Validate($username, $password);
         }
     }
     return false;
 }
예제 #3
0
 public function Validate($username, $password)
 {
     Log::Debug('Attempting to authenticate user against WordPress. User=%s', $username);
     $user = wp_authenticate($username, $password);
     if (is_wp_error($user)) {
         Log::Error('WordPress authentication error: %s', $user->get_error_message());
         return false;
     }
     if ($user->exists()) {
         Log::Debug('WordPress authentication successful. User=%s', $username);
         $this->user = $user;
         $this->password = $password;
         return true;
     } else {
         Log::Debug('WordPress authentication failed. User=%s', $username);
         if ($this->options->RetryAgainstDatabase()) {
             Log::Debug('WordPress authentication retrying against database');
             return $this->authToDecorate->Validate($username, $password);
         }
     }
     return false;
 }