original_string: public function authenticate(Authenticatable $user, array $credentials)
      {
  
          $handler = ldap_connect($this->host);
  
          if (! $handler) {
              throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
          }
  
          try {
              ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
          } catch (\ErrorException $e) {
              ;
          }
  
          $username = strtok($user->email, '@');
  
          $rdn = $this->makeRdn($username);
  
          try {
              $bind = ldap_bind($handler, $rdn, $credentials['password']);
          } catch (\ErrorException $e) {
              $bind = false;
          }
  
          if ($handler) {
              ldap_close($handler);
  
              unset($handler);
          }
  
          if ($bind) {
              $user->save();
          }
  
          return $bind;
      }
code: public function authenticate(Authenticatable $user, array $credentials)
      {
  
          $handler = ldap_connect($this->host);
  
          if (! $handler) {
              throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
          }
  
          try {
              ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
          } catch (\ErrorException $e) {
              ;
          }
  
          $username = strtok($user->email, '@');
  
          $rdn = $this->makeRdn($username);
  
          try {
              $bind = ldap_bind($handler, $rdn, $credentials['password']);
          } catch (\ErrorException $e) {
              $bind = false;
          }
  
          if ($handler) {
              ldap_close($handler);
  
              unset($handler);
          }
  
          if ($bind) {
              $user->save();
          }
  
          return $bind;
      }
code_tokens: public function authenticate ( Authenticatable $ user , array $ credentials ) { $ handler = ldap_connect ( $ this -> host ) ; if ( ! $ handler ) { throw new RuntimeException ( "Connection fail! Check your server address: '{$this->host}'." ) ; } try { ldap_set_option ( $ handler , LDAP_OPT_PROTOCOL_VERSION , 3 ) ; } catch ( \ ErrorException $ e ) { ; } $ username = strtok ( $ user -> email , '@' ) ; $ rdn = $ this -> makeRdn ( $ username ) ; try { $ bind = ldap_bind ( $ handler , $ rdn , $ credentials [ 'password' ] ) ; } catch ( \ ErrorException $ e ) { $ bind = false ; } if ( $ handler ) { ldap_close ( $ handler ) ; unset ( $ handler ) ; } if ( $ bind ) { $ user -> save ( ) ; } return $ bind ; }
docstring: Check user's credentials against LDAP server.
  
  @param  Authenticatable $user
  @param  array           $credentials
  @return bool
docstring_tokens: Check user s credentials against LDAP server .