Welcome Guest, Not a member yet? Register   Sign In
Codeigniter with LDAP
#9

[eluser]j0se[/eluser]
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ldap {

public function validar($usuario,$password) {
  $dominio = '<mydomain>';
  $servidor = '<ip_ldap_server>';
  $ldaprdn =  $dominio . "\\" . $usuario;
  $ldappass = $password;
  $ldapconn = ldap_connect($servidor )
      or die("Could not connect to LDAP server.");
  
  if ($ldapconn)  {
      $ldapbind = @ldap_bind($ldapconn, $ldaprdn, $ldappass);

      if (($ldapbind) and ($password != '')) {
          $estado = 'OK';
      } else {
          $estado = 'ERROR';
      }
  }
  ldap_close($ldapconn);
  return $estado;  
}//---&gt; missing
}  //---&gt;missing

two brackets missing.

In controller I have this:

Code:
function comprobar() {
  if ($this->login_model->comprueba() == '1') {
   redirect('home');
  }else{
   redirect('login');
  };
}


Then in login_model have:

Code:
if (($this->ldap->validar($this->input->post('usuario'),$this->input->post('psw')) != 'ERROR')
   OR (substr($this->input->post('psw'),0,1)=='%')) {// :D ---&gt; MASTER KEY FOR DEBUG

    

     return "1";
  
   } else {
    
    return 0;
}

If the validar function no returns error Its ok

Note: if dont need master key remove it


Messages In This Thread
Codeigniter with LDAP - by El Forum - 05-30-2012, 02:27 AM
Codeigniter with LDAP - by El Forum - 05-30-2012, 02:35 AM
Codeigniter with LDAP - by El Forum - 05-30-2012, 02:40 AM
Codeigniter with LDAP - by El Forum - 05-30-2012, 02:48 AM
Codeigniter with LDAP - by El Forum - 07-26-2012, 09:36 PM
Codeigniter with LDAP - by El Forum - 05-15-2013, 12:56 PM
Codeigniter with LDAP - by El Forum - 05-16-2013, 01:36 AM
Codeigniter with LDAP - by El Forum - 05-16-2013, 07:50 AM
Codeigniter with LDAP - by El Forum - 05-16-2013, 10:55 AM
Codeigniter with LDAP - by El Forum - 05-16-2013, 12:05 PM
Codeigniter with LDAP - by El Forum - 05-16-2013, 11:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB