Пример #1
0
 /**
  * getAuth checks Active Directory for valid credentials and returns true if they are found.
  * @param array $cred
  * @return bool
  * @see Staple_AuthAdapter::getAuth()
  */
 public function getAuth($cred)
 {
     if ($this->checkConfig($this->_settings)) {
         if (array_key_exists('username', $cred) and array_key_exists('password', $cred)) {
             if (strlen($cred['username']) >= 1 && strlen($cred['password']) >= 1) {
                 if (Staple_AD::validchars($cred['username']) == TRUE && Staple_AD::validchars($cred['password']) == TRUE) {
                     $pass = $cred['password'];
                     $LDAP = Staple_AD::get();
                     $this->uid = $cred['username'];
                     if ($LDAP->bind($this->uid, $pass)) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Пример #2
0
 /** 
  * 
  * Verifies user credentials based on username and password provided, then resestablishes
  * management user connection to Active Directory.
  * @param $uname
  * @param $pword
  */
 public function bind($uname, $pword)
 {
     try {
         if (ldap_bind($this->LDAPConn, Staple_AD::usrlogin($uname), $pword)) {
             $this->mgmtbind();
             return TRUE;
         } else {
             $this->mgmtbind();
             return FALSE;
         }
     } catch (Exception $e) {
         $this->mgmtbind();
         return FALSE;
     }
 }