Hello,
I'm having some problem with LDAP Database Auth.
The problem is that in my LDAP we don't use the field password. We use the field userPassword.
With this, a problem occur when I try to login.
Here is the log of application:
[2021-01-13 08:28:20] testing.ERROR: Undefined array key "password" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"password\" at /home/biffe/Desenvolvimento/passaporte-ifpr/vendor/directorytree/ldaprecord-laravel/src/Auth/DatabaseUserProvider.php:185)
[2021-01-13 08:28:20] testing.INFO: Object with name [xxx] has been successfully synchronized.
[2021-01-13 08:28:20] testing.INFO: Object with name [xxx] is being synchronized.
[2021-01-13 08:28:20] testing.INFO: Object with name [xxx] is being imported.
[2021-01-13 08:28:20] testing.INFO: User [xxx] has been successfully discovered for authentication.
[2021-01-13 08:28:20] testing.INFO: LDAP (xxx) - Operation: Search - Base DN: dc=xxx,dc=ga - Filter: (&(objectclass=person)(objectclass=inetOrgPerson)(objectclass=brPerson)(objectclass=schacPersonalCharacteristics)(mail=xxx)(userPassword=xxx)) - Selected: (*,uid,objectclass) - Time Elapsed: 638.92
[2021-01-13 08:28:20] testing.INFO: LDAP (xxx) - Operation: Bound - Username: cn=xxx
[2021-01-13 08:28:19] testing.INFO: LDAP (xxx) - Operation: Binding - Username: cn=xxx
I used the instructions of the documentation (https://ldaprecord.com/docs/laravel/v2/auth/database/installation/).
I tried use with Laravel UI.
This is my auth file:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'ldap' => [
'driver' => 'ldap',
'model' => App\Ldap\User::class,
'rules' => [],
'database' => [
'model' => App\Models\User::class,
'sync_passwords' => true,
'sync_attributes' => [
'name' => 'cn',
'email' => 'mail',
],
'sync_existing' => [
'email' => 'mail',
],
'password_column' => 'userPassword',
],
],
and the LoginController.php
protected function credentials(Request $request)
{
return [
'mail' => $request->email,
'userPassword' => "{SSHA}" . base64_encode(sha1($request->password)),
];
}
Any suggestions of what I'm doing wrong?
Thanks?
Hi @abiffe,
Issue 1:
The problem is that in my LDAP we don't use the field password. We use the field userPassword.
You don't need to change anything if your LDAP server uses the field userPassword. This doesn't affect authentication in any way.
Issue 2:
'password_column' => 'userPassword',
Only set the password_column configuration option if you have a different SQL column name for your password field inside of your users database table.
Issue 3:
You do not need to hash the password inside of the credentials() method. You should simply use:
protected function credentials(Request $request)
{
return [
'mail' => $request->email,
'password' => $request->password,
];
}
Resolution:
password_column configuration option inside of your config/auth.php fileLoginController::credentials() method as shown aboveAfter performing the above steps, you should be able to authenticate 馃憤
Let me know!
@stevebauman Thank you very much, It worked now.
Awesome @abiffe! That's great that you're up and running.
Happy to help 馃槃