title: Convert conventional PHP LDAP login code to Laravel LDAP code
body: <p>I'm newbie to Laravel and even Frameworks... I've tried some basic authentication in Laravel. Now here's my problem. I've got an LDAP login script in conventional PHP and I want to switch to Laravel LDAP login. Can anyone help me with the code/bundle or anything? I'll be very grateful for this help.</p>
  
  <pre><code>function check_login($username,$password){
      if($username=="" || $password=="")
          return 1 ;
      $server1="ldap.xyz.com";   //server1 ip or dns
      $server2="ldap.xyz.com";  //server2 ip or dns
  
      $firstqry=array("alias,sn,givenname,mail,dn");
      $secqry=array("givenname,jobtitledescription,sn,alias,mail,l,employeenumber");
  
      $firstfilter="(alias=$username)";
      $searchin="o=XYZ,c=AN";
  
  
      $ldap=ldap_connect($server1,389);
      if (!($res = @ldap_bind($ldap))) {
        //echo "&lt;b&gt;Cannt Contact Server 1 :" .$server1 .", Now Contacting Server 2 :".$server2. ".....&lt;/b&gt;&lt;br&gt;";
        $laststatus=ldap_errno($ldap);
        if($laststatus==81){
           $ldap=ldap_connect($server2,389);
           if (!($res = @ldap_bind($ldap))) {
              //echo "&lt;b&gt;Cannt Contact Server 2 :" .$server2 ."...&lt;/B&gt;&lt;br&gt;";
              $laststatus=ldap_errno($ldap);
              if($laststatus==81){
                 //echo "&lt;b&gt;Please Contact The Network Adminstartion!!&lt;/b&gt;&lt;br&gt;";
                 return 2 ; // server not found
              }
           }else{
                 $laststatus=ldap_errno($ldap);
           }
        }
      }else{
        $laststatus=ldap_errno($ldap);
      }
  
      //echo "Connection :" .ldap_error($ldap)."&lt;br&gt;";
      if($laststatus==0){
          $sr=ldap_search($ldap,$searchin,$firstfilter,$firstqry);
          $info = ldap_get_entries($ldap, $sr);
          for ($i=0; $i&lt;$info["count"]; $i++) {
              $searchdn=$info[$i]["dn"];
              $searchalias=$info[$i]["alias"][0];
          }
  
          if($searchdn){
              $secfilter=$firstfilter;
              $sr2=ldap_search($ldap,$searchin,$secfilter);
              $info2 = ldap_get_entries($ldap, $sr2);
              $i=0;
              if(count($info2)){
                  if (!($res = @ldap_bind($ldap,$searchdn,addslashes($password)))) {
                    return 1 ;
                  }else{
                      ldap_close($ldap);
                      return 0 ;
                  }
              }
          }else{
              return 1 ;
          }
      }
  }
  </code></pre>