Closed martijnimhoff closed 7 years ago
Hi @martijnimhoff, no problem at all, I'd be glad to help you out! :)
Can you post your config/adldap_auth.php
file?
Thank you. this is my adldap_auth.php
return [
'connection' => env('ADLDAP_CONNECTION', 'default'),
'username_attribute' => ['username' => 'samaccountname'],
'limitation_filter' => env('ADLDAP_LIMITATION_FILTER', ''),
'login_fallback' => env('ADLDAP_LOGIN_FALLBACK', false),
'password_key' => env('ADLDAP_PASSWORD_KEY', 'password'),
'password_sync' => env('ADLDAP_PASSWORD_SYNC', true),
'login_attribute' => env('ADLDAP_LOGIN_ATTRIBUTE', 'samaccountname'),
'windows_auth_attribute' => ['samaccountname' => 'AUTH_USER'],
'bind_user_to_model' => env('ADLDAP_BIND_USER_TO_MODEL', false),
'sync_attributes' => [
'name' => 'cn',
],
'select_attributes' => [
//
],
];
And in my .env
I've set ADLDAP_PASSWORD_SYNC=true
. as well as ADLDAP_ADMIN_USERNAME
,
ADLDAP_ADMIN_PASSWORD
, ADLDAP_LIMITATION_FILTER
Looks like you're using a username instead of an email to authenticate:
'username_attribute' => ['username' => 'samaccountname'],
Did you update your create_users_table
migration to create a username
column instead of email
?
You'll also need to update your controller as specified in the quick start doc (below):
If you require logging in by another attribute, such as a username instead of email follow the process below for your Laravel version. Otherwise ignore this step.
Laravel <= 5.2: Inside the generated app/Http/Controllers/Auth/AuthController.php, you'll need to add the protected $username property if you're logging in users by username.
class AuthController extends Controller
{
protected $username = 'username';
Laravel > 5.3: Inside the generated app/Http/Controllers/Auth/LoginController.php, you'll need to add the public method username():
public function username()
{
return 'username';
}
Thanks for your reply! It works now. I added the username() method, updated the fields in the login.blade.php and changed the create_users_table
What was confusing for me is that the LoginController.php is actually a basic laravel file. So it's not generated.
Great! Glad you've resolved the issue :).
I'm a bit new to laravel, so please forgive me for asking stupid questions :) I'm using laravel 5.3.
I followed the quickstart readme. Using
Adldap::auth()->attempt($username, $password);
with a correct password and username works for me. And I can retrieve lists of users etc. However the login form doesn't work. I get the error of wrong credentials.I think my login controller is still looking for the credentials in the current user model. My login controller currently is the basic laravel login controller
Could someone add the instructions / help me with getting this to work?