Ejemplo n.º 1
0
 /**
  * Get an instance of the LDAP object
  *
  * @return LDAP
  */
 protected function getLdap()
 {
     $now = time();
     if ($this->connectionLastUsed && $this->ldap && $now - $this->connectionLastUsed > self::RESET_TIMEOUT) {
         $this->ldap->close();
         $this->ldap = null;
     }
     $this->connectionLastUsed = $now;
     if (!empty($this->ldap)) {
         return $this->ldap;
     }
     $this->ldap = new Ldap($this->ldapUrl);
     $this->ldap->setOption(Ldap::OPT_NETWORK_TIMEOUT, 10);
     $this->ldap->bind($this->ldapBindUser, $this->ldapBindPassword);
     return $this->ldap;
 }
 /**
  * @return boolean
  * @param string $user
  * @param string $password
  */
 private function _validateSMB4($user, $password, $onlyCheckIsExistsUser = false)
 {
     //Conexao com o servidor...
     $connection = $this->_ldap->connect(Config::factory()->getParam('extra.ldap.samba4.host'), Config::factory()->getParam('extra.ldap.samba4.port'), Config::factory()->getParam('extra.ldap.samba4.version'));
     //Autenticar o Administrador...
     $this->_ldap->bind($connection, Config::factory()->getParam('extra.ldap.samba4.user'), Config::factory()->getParam('extra.ldap.samba4.password'));
     //Recuperar DN do usuario para autenticacao...
     $user = $this->_ldap->search($connection, Config::factory()->getParam('extra.ldap.samba4.dn'), Config::factory()->getParam('extra.ldap.samba4.filter') . $user, array('dn'));
     //Verificar se o usuario existe...
     if (count($user) > 1) {
         if ($onlyCheckIsExistsUser) {
             return 4;
         }
     } else {
         return 5;
     }
     //Autenticar o Usuario...
     $status = $this->_ldap->bind($connection, $user[0]['dn'], $password);
     //Fechar Conexao...
     $this->_ldap->close($connection);
     return $status;
 }