I am in charge of creating a new laravel project where the authentication is made by our LDAP. I am pretty new to laravel so excuse me for my lack of comprehension
I am trying to use this library : Adldap2-Laravel
I followed this documentation to build the authentification from scratch.
So my config/app.php have those lines added
//In providers array
Adldap\Laravel\AdldapServiceProvider::class,
Adldap\Laravel\AdldapAuthServiceProvider::class,
//In aliases
'Adldap' => Adldap\Laravel\Facades\Adldap::class,
And my config/auth.php (I also tried to only use the adldap driver, without success)
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'users' => [
'driver' => 'adldap',
'model' => App\User::class,
],
],
Everything looks right. But I can not auth, I have this error : These credentials do not match our records.
When I use this code
use Adldap\Laravel\Facades\Adldap;
$username = "myUser";
$password = "myPassword";
if (Adldap::auth()->attempt($username, $password)) {
//Queries here
}
else
{
echo "Auth failed";
}
I CAN perform queries, and the authentication works with all my users. But I can not use properly the login form behind the "Login" button.
Did I miss something ?
I do not know if the authentication should work directly without importing anything but I also tried to run this command
php artisan adldap:import
All my users are found and inserted in the laravel DB. But the authentication still does not work.
I deleted the ADLDAP_ACCOUNT_SUFFIX=
from my .env file
And added the suffix directly in ADLDAP_ADMIN_USERNAME=Administrator@mycompany.something
Now I'm able to connect via the email address.
I do not know if it is the best solution but at least it works.
I let this post open for a few days to see if someone have a better idea
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.