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

[eluser]kashyap8811[/eluser]
this code is continue in authentication.php file.

Code:
else {  
      $return_obj[RET_STATUS] = RET_ERROR;
      $return_obj[RET_MESSAGE] = "Invalid credentials.(username or password is wrong.)";
      log_message('error', "Failed login attempt by : Username : " . $username . " from " . $this->ci->input->ip_address() . " at " . date('d-m-y H:i:s'));
      ldap_unbind($ldapConnection);
      return $return_obj;
      }  
        }
     } catch (adLDAPException $e) {
    $return_obj[RET_STATUS] = RET_ERROR;
    $return_obj[RET_MESSAGE] = $e;
    log_message('error', $e);
    syslog(LOG_ERR, $e);
    return $return_obj;
   }  
   }
}
?>


Now create one controller file and load library file.
Code:
$this->load->library('authentication');

if($_POST) {  
  
   $adldap = new authentication();

   $username=strtoupper($this->input->post('username'));
   $password=$this->input->post('password');
  
   $data['username']=$username;
   $data['password']=$password;      
  
   $return_obj = array();    
    
   try {        
        
        $user_obj =$adldap->authenticate($username, $password);
      
       //authenticate the user
       if ($user_obj){      
        if($user_obj[RET_STATUS]==RET_OK){        
          echo "<br/>Successfully logged in by Username : ".$username."<br/>";
            echo RET_FIRSTNAME." :: ".$user_obj[RET_FIRSTNAME]; echo "<br/>";
         echo RET_LASTNAME." :: ".$user_obj[RET_LASTNAME]; echo "<br/>";
         echo RET_DISPLAYNAME." :: ".$user_obj[RET_DISPLAYNAME]; echo "<br/>";
         echo RET_EMAIL." :: ".$user_obj[RET_EMAIL]; echo "<br/>";
         echo RET_DEPARTMENT." :: ".$user_obj[RET_DEPARTMENT]; echo "<br/>";
         echo RET_USERID." :: ".$user_obj[RET_USERID]; echo "<br/><br/>";
          
          //syslog('LOG_INFO', 'User Authenticated');              
        
          echo "LDAP Server closed";
          
          $data['error']='';
          $this->load->view('view_detail',$data);
        
        } else {
         $user_obj[RET_STATUS] = RET_ERROR;
         $data['error']=$user_obj[RET_MESSAGE];
           $this->load->view('login',$data);
           }
       } else {
        $user_obj[RET_STATUS] = RET_ERROR;
        $data['error']=$user_obj[RET_MESSAGE];  
         $this->load->view('login',$data);  
       }
    
    } catch (adLDAPException $e) {
     $data['error']=$e;
     $this->load->view('login',$data);
     exit();
    }    
    
    } else {
    
   $data["error"] ='';
    
   $data['username']=$this->input->post('username');
   $data['password']=$this->input->post('password');  
   $this->load->view('login',$data);
    
    }


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