Ldaprecord-laravel: Errors with /vendor/directorytree/ldaprecord-laravel/src/Hydrators/PasswordHydrator.php

Created on 14 Apr 2020  路  6Comments  路  Source: DirectoryTree/LdapRecord-Laravel

Describe the bug
I am trying to configure without the use of password syncing.

I get the following error:
Too few arguments to function IlluminateDatabaseEloquentModel::setAttribute(), 1 passed in /srv/sites/dev/steve/projects/doav3/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 675 and exactly 2 expected

This is resulting from lines 43 - 51 of the PasswordHydrator.php file
protected function setPassword(EloquentModel $model, $password)
{
// If the model has a mutator for the password field, we
// can assume hashing passwords is taken care of.
// Otherwise, we will hash it normally.
$password = $model->hasSetMutator($this->passwordColumn()) ? $password : Hash::make($password);

    $model->setAttribute($this->passwordColumn(), $password);
}

My config is here :

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
    'ldap' => [
        'driver' => 'ldap',
        'model' => LdapRecord\Models\ActiveDirectory\User::class,
        'rules' => [],
        'database' => [
            'model' => App\User::class,
            'password_column' => null,
            'sync_passwords' => false,
            'sync_attributes' => [
                'name' => 'cn',
                'username' => 'samaccountname',
                'email' => 'mail',
            ],
        ],
    ],

If I comment out those lines of code in the PasswordHydrator.php file, it works fine .. but I am not comfortable with that option going forward.

Love the library by the way.

Environment (please complete the following information):

  • LDAP Server Type: ActiveDirectory
  • PHP Version: 7.2.17
  • Laravel Version: 7.6.1

Most helpful comment

Yup I documented this incorrectly:

https://ldaprecord.com/docs/laravel/auth/configuration/#database-password-column

You can also set the value to null if your database table does not have any password column at all:

Fixing now 馃槃

All 6 comments

Hi @stephenucr,

Thanks for your kind words! I鈥檓 glad you like LdapRecord 馃槃

To resolve your issue, set password_column to false instead of null.

I may have documented this incorrectly, let me make sure it鈥檚 correct.

Give the above a shot and let me know if it works!

OMG .. Awesome! Thanks so much, that worked.

Yup I documented this incorrectly:

https://ldaprecord.com/docs/laravel/auth/configuration/#database-password-column

You can also set the value to null if your database table does not have any password column at all:

Fixing now 馃槃

Glad you're up and running @stephenucr! Also just fixed this in the docs -- it's now live. Thanks!

thanks for the quick response !

No worries! Please feel free to drop another issue if you have any further questions or need assistance. 馃憤

Was this page helpful?
0 / 5 - 0 ratings