title: Codeigniter Application with LDAP Authentication
body: <p>Without codeigniter i am able to use ldap_connect() but in the codeigniter project i want to use ldap connection for authenticating user with their windows username and password. Below is the code which is working perfect without codeigniter. </p>
  
  <pre><code>/******LDAP CONNECTIVITY STARTS HERE*********/
  $ldaprdn = $_POST['uname']; // ldap rdn or dn
      $ldappass = $_POST['upass']; // associated password
      $ldaprdn = $_POST['uname'].'@domain.com';
      $ldapconn = ldap_connect("ip") or die("Could not connect to LDAP server."); //our ip
  if ($ldapconn) {
      $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
          // verify binding
          if ($ldapbind) {
              //echo "&lt;pre&gt;";
              //print_r($row_login);
              //exit;
  
              $_SESSION['appusername']=$_POST['uname'];
              $_SESSION['emp_code']=$row_login['emp_code'];
              $_SESSION['emp_id']=$row_login['emp_id'];
              $_SESSION['emp_name']=$row_login['emp_name'];
              $_SESSION['emp_email']=$row_login['emp_email'];
              $_SESSION['emp_dept_id']=$row_login['emp_dept_id'];
              $_SESSION['emp_dept_name']=$row_login['dept_name'];
              $_SESSION['emp_group']=$row_login['emp_group'];
              $_SESSION['emp_category']=$row_login['emp_category'];
  
              $_SESSION['finance_app_authority']=$row_login['finance_approval_status'];
              $_SESSION['line_eng_status']=$row_login['line_eng_status'];
  
              $_SESSION['line_name']=$row_login['line_name'];
              $_SESSION['dept_name']=$row_login['dept_name'];
  
              if($row_login['emp_mod_status']=='Y'){ //if moderator means
                  $_SESSION['userType']='MOD';
              }
              else if($row_login['emp_id']==$row_login['dept_hod_id']){ //if HOD means
                  $_SESSION['userType']='HOD';
              }else{ //if normal user means
                  $_SESSION['userType']='EMP';
              }
              echo '&lt;script language="javascript"&gt;document.location.href="?p=main&amp;m=it-home"&lt;/script&gt;';
              exit;
  
          }
          else{
          echo '&lt;div  class="man_style" style="width:50%;padding:10px 10px 10px 250px !important;text-align:center;color:red;"&gt;Invalid password.&lt;/div&gt;';
          }
      }
  </code></pre>
  
  <p>All i want is to authenticate user by windows username and password in codeigniter. Suggest me a very simple way please.</p>
  
  <p>I tried Auth_Ldap library but still i am getting an error</p>
  
  <blockquote>
    <p>LDAP functionality not present. Either load the module ldap php module or use a php with ldap support compiled in.</p>
  </blockquote>
  
  <p>I have used Auth_Ldap library file. the following config file
  Don't know where to give my host ip address</p>
  
  <pre><code>$config['account_suffix']       = '@abcd.com';
  $config['base_dn']              = 'DC=domain,DC=local';
  $config['domain_controllers']   = array ("server1.domain.local");
  $config['ad_username']          = 'administrator';
  $config['ad_password']          = 'password';
  $config['real_primarygroup']    = true;
  $config['use_ssl']              = false;
  $config['use_tls']              = false;
  $config['recursive_groups']     = true;
  
  
  /* End of file adldap.php */
  /* Location: ./system/application/config/adldap.php */
  </code></pre>
  
  <p>Your help is appreciated</p>