- Laravel Version: 5.4
- Adldap2-Laravel Version: "^3.0",
- PHP Version: 5.6.30
I managed to make the connection work to the AD, but I can't seem to make the Auth::attempt work. It will always return false. Anyone got an idea, or a hint?
public function login(Request $request) {
$search = Adldap::search()->where('samaccountname', '=', 'tba')->get();
// this is returning the correct user
dd($search);
//'username' => 'tba'
// 'passwrod' => 'is the entered password'
//this goes into error part
if (Auth::attempt(request()->only('username', 'password'))) {
dd('success');
} else {
dd('error');
}
}
'usernames' => [
/*
|--------------------------------------------------------------------------
| LDAP
|--------------------------------------------------------------------------
|
| This is the LDAP users attribute that you use to authenticate
| against your LDAP server. This is usually the users
|'sAMAccountName' / 'userprincipalname' attribute.
|
| If you'd like to use their username to login instead, insert `samaccountname`.
|
*/
'ldap' => 'samaccountname',
/*
|--------------------------------------------------------------------------
| Eloquent
|--------------------------------------------------------------------------
|
| This is the attribute that is used for locating
| and storing the LDAP username above.
|
| If you're using a `username` field instead, change this to `username`.
|
| This option is only applicable to the DatabaseUserProvider.
|
*/
'eloquent' => 'username',
ah right and
Adldap::auth()->attempt(request()->only('username', 'password'))
is giving me an ErrorException: Missing argument 2 for Adldap\Auth\Guard::attempt(), called in /media/sf_www/prm/app/Http/Controllers/Auth/LoginController.php on line 63 and defined<
UPDATE:
I managed to get to the success:
if (Adldap::auth()->attempt(request()->get('username'), request()->get('password'))) {
dd('success');
} else {
dd('error');
}
I can get to the success, the strange thing is I have to use the CN name as user name. if I use the samaccountname which is "tba" it doesn't work.
More then so interesting is that Auth isn't working at all. Returns False
Auth::attempt(request()->only('username', 'password'))
I could need some help/introductions here.