title: Laravel LDAP Authentication not working - LdapRecord Package
body: <p>I'm trying to implements an LDAP authentication in an application for my company. I'm using Laravel 5.8 and the LdapRecord package (<a href="https://github.com/DirectoryTree/LdapRecord-Laravel" rel="nofollow noreferrer">https://github.com/DirectoryTree/LdapRecord-Laravel</a>).</p>
  
  <p>I have succeed to connect the application with the LDAP server but the authentication still not working and idk why... :(</p>
  
  <p>Here is my code :</p>
  
  <p><strong>The LoginController</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  use LdapRecord\Container;
  use Illuminate\Http\Request;
  use App\User;
  
  class LoginController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles authenticating users for the application and
      | redirecting them to your home screen. The controller uses a trait
      | to conveniently provide its functionality to your applications.
      |
      */
      use AuthenticatesUsers;
  
      /**
       * LDAP Connection 
       */
      private $connection;
  
      /**
       * Where to redirect users after login.
       *
       * @var string
       */
      protected $redirectTo = '/home';
  
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          $this-&gt;connection = Container::getConnection('default');
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  
      public function username() {
          return 'username';
      }
  
      protected function credentials(Request $request)
      {
          return [
              'comptent' =&gt; $request-&gt;username,
              'password' =&gt; $request-&gt;password,
          ];
      }
  }
  
  </code></pre>
  
  <p>Here is the configuration - <strong>auth.php</strong> : </p>
  
  <pre class="lang-php prettyprint-override"><code>    'guards' =&gt; [
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'ldap',
          ],
  // some code
      'providers' =&gt; [
          'users' =&gt; [
              'driver' =&gt; 'eloquent',
              'model' =&gt; App\Ldap\User::class,
          ],
          'ldap' =&gt; [
              'driver' =&gt; 'ldap',
              'model' =&gt; LdapRecord\Models\ActiveDirectory\User::class,
              'rules' =&gt; [],
              'database' =&gt; [
                  'model' =&gt; App\Ldap\User::class,
                  'sync_passwords' =&gt; false,
                  'sync_attributes' =&gt; [
                      'LASTNAME' =&gt; 'sn',
                      'FIRSTNAME' =&gt; 'givenname',
                      'ACTIVE_DIRECTORY_USER' =&gt; 'comptent'
  </code></pre>
  
  <p>The user model - <strong>User.php</strong>:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App\Ldap;
  
  //use Illuminate\Database\Eloquent\Model;
  use LdapRecord\Laravel\Auth\HasLdapUser;
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
  use LdapRecord\Laravel\Auth\LdapAuthenticatable;
  use LdapRecord\Models\Model;
  
  /**
   * Class User
   * 
   * @property int $ID_USER
   * @property string $LASTNAME
   * @property string $FIRSTNAME
   * @property string $ACTIVE_DIRECTORY_USER
   * @property int $ID_ROLE
   * 
   * @property Role $role
   *
   * @package App\Models
   */
  class User extends Model
  {
  
      use Notifiable, AuthenticatesWithLdap;
  
      /**
       * The object classes of the LDAP model.
       *
       * @var array
       */
      public static $objectClasses = [];
      protected $table = 'user';
      protected $primaryKey = 'ID_USER';
      public $incrementing = false;
      public $timestamps = false;
  
      protected $casts = [
          'ID_USER' =&gt; 'int',
          'ID_ROLE' =&gt; 'int'
      ];
  
      protected $fillable = [
          'LASTNAME',
          'FIRSTNAME',
          'ACTIVE_DIRECTORY_USER',
          'ID_ROLE'
      ];
  
      public function role()
      {
          return $this-&gt;belongsTo(Role::class, 'ID_ROLE');
      }
  }
  </code></pre>
  
  <p>Here is some logs that i have when i try to login : </p>
  
  <pre><code>[2020-02-19 15:49:12] local.INFO: LDAP (ldap://srv-gldap1:389) - Operation: Listing - Base DN: ou=utilisateurs,dc=rms,dc=fr - Filter: (objectclass=*) - Selected: (*) - Time Elapsed: 922.65  
  [2020-02-19 15:49:12] local.INFO: LDAP (ldap://srvil-gdldap1:389) - Operation: Search - Base DN: ou=utilisateurs,dc=rms,dc=fr - Filter: (comptentdomaine=hippolyte.massicot@rms.local) - Selected: (*) - Time Elapsed: 101.91
  </code></pre>
  
  <p>Is there anyone who has already used this package and can help me on my code ? 
  thank you in advance :)  </p>