Adldap2 / Adldap2-Laravel

LDAP Authentication & Management for Laravel
MIT License
910 stars 184 forks source link

Unable to login using LDAP and Active Directory - Followed tutorial #728

Closed LetitiaJD closed 5 years ago

LetitiaJD commented 5 years ago

Description:

I followed this tutorial step by step, but unfortunately I am unable to login. I think I have missed something out in the configuration steps, but I am unsure how to proceed.

@stevebauman Please can you assist?

I have done the following:

  1. Created a new laravel project called returns by running the following command: laravel new returns

  2. I ran the following command to install Adldap2-Laravel: composer require adldap2/adldap2-laravel

  3. I created a new MySQL database and called it returns

  4. I entered the database details into my .env file and tested the connection, which was successful

  5. I am using usernames instead of email addresses to login, so I changed the default "email" column in database/migrations/2014_10_12_000000_create_users_table.php

  6. I then ran php artisan migrate to migrate the tables, which was successful

  7. I inserted the following into config/app.php (in the providers array):

    Adldap\Laravel\AdldapServiceProvider::class,
    Adldap\Laravel\AdldapAuthServiceProvider::class,
  8. I inserted the facade into config/app.php (in the aliases array):

    'Adldap' => Adldap\Laravel\Facades\Adldap::class,
  9. I ran php artisan vendor:publish and to files were published in my config folder: ldap.php and ldap_auth.php

  10. The modified the aforementioned config files, however I am not sure if they are correct. Please see the files below. I have removed the comments to make it take up less room.

ldap.php

<?php

return [
    'logging' => env('LDAP_LOGGING', false),

    'connections' => [
        'default' => [
            'auto_connect' => env('LDAP_AUTO_CONNECT', true),

            'connection' => Adldap\Connections\Ldap::class,

            'settings' => [
                'schema' => Adldap\Schemas\ActiveDirectory::class,
                'account_prefix' => env('LDAP_ACCOUNT_PREFIX', ''),
                'account_suffix' => env('LDAP_ACCOUNT_SUFFIX', ''),
                'hosts' => explode(' ', env('LDAP_HOSTS', 'dc01.ad.hygi.de dc02.ad.hygi.de')),
                'port' => env('LDAP_PORT', 389),
                'timeout' => env('LDAP_TIMEOUT', 5),
                'base_dn' => env('LDAP_BASE_DN', 'OU=ad.hygi.de,DC=ad,DC=hygi,DC=de'),
                'username' => env('LDAP_USERNAME'),
                'password' => env('LDAP_PASSWORD'),
                'follow_referrals' => false,
                'use_ssl' => env('LDAP_USE_SSL', false),
                'use_tls' => env('LDAP_USE_TLS', false),
            ],
        ],
    ],
];

ldap_auth.php

<?php
return [
    'connection' => env('LDAP_CONNECTION', 'default'),
    'provider' => Adldap\Laravel\Auth\DatabaseUserProvider::class,
    'model' => App\User::class,

    'rules' => [
        // Denys deleted users from authenticating.
        Adldap\Laravel\Validation\Rules\DenyTrashed::class,

        // Allows only manually imported users to authenticate.
        // Adldap\Laravel\Validation\Rules\OnlyImported::class,
    ],

    'scopes' => [

        // Only allows users with a user principal name to authenticate.
        // Suitable when using ActiveDirectory.
        Adldap\Laravel\Scopes\UpnScope::class,

        // Only allows users with a uid to authenticate.
        // Suitable when using OpenLDAP.
        // Adldap\Laravel\Scopes\UidScope::class,

    ],

    'identifiers' => [

        'ldap' => [
            'locate_users_by' => 'userprincipalname',
            'bind_users_by' => 'distinguishedname',
        ],

        'database' => [
            'guid_column' => 'objectguid',
            'username_column' => 'username',
        ],

        'windows' => [
            'locate_users_by' => 'samaccountname',
            'server_key' => 'AUTH_USER',
        ],

    ],

    'passwords' => [
        'sync' => env('LDAP_PASSWORD_SYNC', false),
        'column' => 'password',
    ],

    'login_fallback' => env('LDAP_LOGIN_FALLBACK', false),

    'sync_attributes' => [
        'username' => 'userprincipalname',
        'name' => 'cn',
    ],

    'logging' => [
        'enabled' => env('LDAP_LOGGING', true),
        'events' => [
            \Adldap\Laravel\Events\Importing::class => \Adldap\Laravel\Listeners\LogImport::class,
            \Adldap\Laravel\Events\Synchronized::class => \Adldap\Laravel\Listeners\LogSynchronized::class,
            \Adldap\Laravel\Events\Synchronizing::class => \Adldap\Laravel\Listeners\LogSynchronizing::class,
            \Adldap\Laravel\Events\Authenticated::class => \Adldap\Laravel\Listeners\LogAuthenticated::class,
            \Adldap\Laravel\Events\Authenticating::class => \Adldap\Laravel\Listeners\LogAuthentication::class,
            \Adldap\Laravel\Events\AuthenticationFailed::class => \Adldap\Laravel\Listeners\LogAuthenticationFailure::class,
            \Adldap\Laravel\Events\AuthenticationRejected::class => \Adldap\Laravel\Listeners\LogAuthenticationRejection::class,
            \Adldap\Laravel\Events\AuthenticationSuccessful::class => \Adldap\Laravel\Listeners\LogAuthenticationSuccess::class,
            \Adldap\Laravel\Events\DiscoveredWithCredentials::class => \Adldap\Laravel\Listeners\LogDiscovery::class,
            \Adldap\Laravel\Events\AuthenticatedWithWindows::class => \Adldap\Laravel\Listeners\LogWindowsAuth::class,
            \Adldap\Laravel\Events\AuthenticatedModelTrashed::class => \Adldap\Laravel\Listeners\LogTrashedModel::class,
        ],
    ],

];
  1. I added the public method username() to LoginController.php

  2. I inserted a new auth driver into config/auth.php

    'providers' => [
    'users' => [
      'driver' => 'ldap', // Was 'eloquent'.
      'model'  => App\User::class,
    ],
    ],
  3. Inside resources/views/auth/login.blade.php I replaced "email" with "username".

  4. I noticed in ldap.php it said that a username and password is required to be able to query and run operations on the server, so I added both to my .env file: LDAP_USERNAME: LDAP_PASSWORD:

  5. I then went to my domain's page, clicked on login and it just refreshed the page. Nothing else happened. It didn't display an error message or anything.

Please can anyone provide some assistance? I'm pretty new to Laravel and LDAP, so sorry if I am missing something very obvious.

Thanks! :)

stevebauman commented 5 years ago

Hey @LetitiaJD, I'd be glad to help you get up and running!

There's a setup missing from the quick-start tutorial for the auth driver - I'm working on updating all documentation, I apologize.

In your users database table migration, you must also specify an objectguid column to store your LDAP users ObjectGUID. This is mentioned in the upgrade guide and setup but not inside the quick start.

After doing this, enable logging inside your config/ldap.php file, try logging in again, and then check your logs in the storage/logs directory and see what is output.

Let me know how it goes and I can continue helping from there. :smile:

LetitiaJD commented 5 years ago

Hey @LetitiaJD, I'd be glad to help you get up and running!

There's a setup missing from the quick-start tutorial for the auth driver - I'm working on updating all documentation, I apologize.

In your users database table migration, you must also specify an objectguid column to store your LDAP users ObjectGUID. This is mentioned in the upgrade guide and setup but not inside the quick start.

After doing this, enable logging inside your config/ldap.php file, try logging in again, and then check your logs in the storage/logs directory and see what is output.

Let me know how it goes and I can continue helping from there. smile

Hey @stevebauman. Thank you for replying so quickly!

I added the objectguid column and re-ran the migration to update the users table, which was successful.

I turned on logging, tried logging in again and my log file says the following:

Next Adldap\Auth\BindException: Invalid credentials in /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php:109
Stack trace:
#0 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php(121): Adldap\Auth\Guard->bind('XXXXX', 'XXXXXXX')
#1 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Connections/Provider.php(234): Adldap\Auth\Guard->bindAsAdministrator()
#2 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(106): Adldap\Connections\Provider->connect()
#3 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(67): Adldap\Laravel\AdldapServiceProvider->addProviders(Object(Adldap\Adldap), Array)
#4 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application), Ar$
#5 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#6 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\AdldapIn...', Array)
#7 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\AdldapIn...', Array)
#8 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapAuthServiceProvider.php(55): Illuminate\Foundation\Application->make('Adldap\\AdldapIn...')
#9 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapAuthServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application)$
#10 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#11 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\Laravel\\...', Array)
#12 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\Laravel\\...', Array)
#13 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(1225): Illuminate\Foundation\Application->make('Adldap\\Laravel\\...')
#14 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(175): Illuminate\Container\Container->offsetGet('Adldap\\Laravel\\...')
#15 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(144): Illuminate\Support\Facades\Facade::resolveFacadeInstance('Adldap\\Laravel\\...')
#16 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(231): Illuminate\Support\Facades\Facade::getFacadeRoot()
#17 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/Auth/DatabaseUserProvider.php(38): Illuminate\Support\Facades\Facade::__callStatic('byCredentials', Array)
#18 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(349): Adldap\Laravel\Auth\DatabaseUserProvider->retrieveByCredentials(Array)
#19 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(81): Illuminate\Auth\SessionGuard->attempt(Array, false)
#20 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(44): App\Http\Controllers\Auth\LoginController->attemptLogin(Object(Illuminate\Http\Request))
#21 [internal function]: App\Http\Controllers\Auth\LoginController->login(Object(Illuminate\Http\Request))
#22 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#23 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('login', Array)
#24 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\A$lers\Auth\LoginController), 'login')
#25 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#26 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#27 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /srv/htdocs/projects/returns/app/Http/Middleware/RedirectIfAuthenticated.php(24): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Requ$
#35 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure$
#36 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#44 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closu$
#45 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#52 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#53 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#54 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#55 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#56 /srv/htdocs/projects/returns/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#57 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#58 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#59 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#60 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#61 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#62 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#63 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#64 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#65 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Req$
#66 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closur$
#67 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#68 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\H$
#69 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object$
#70 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#71 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#72 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#73 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#74 /srv/htdocs/projects/returns/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#75 {main}

So it is saying that I have invalid credentials, but they are 100% correct. (I hashed them out in the log file.)

In ldap.php it says "When connecting to your LDAP server, a username and password is required to be able to query and run operations on your server(s). You can use any user account that has these permissions. This account does not need to be a domain administrator unless you require changing and resetting user passwords."

I used my credentials; I do not have admin access, but I shouldn't need it, should I?

stevebauman commented 5 years ago

Hey @stevebauman. Thank you for replying so quickly!

No problem!

I used my credentials; I do not have admin access, but I shouldn't need it, should I?

No you don't need an account with admin - only if you are needing to perform user account changes such as password resets etc. I only use an account with read-only access in our domain.

For your configured LDAP_USERNAME - what username format are you using? You can only use either a userPrincipalName which will be in the format of user@domain.local or a full DistinguishedName which must be in the format of cn=John Doe,dc=domain,dc=local. You won't be able to authenticate with sAMAccountName's.

LetitiaJD commented 5 years ago

Hey @stevebauman. Thank you for replying so quickly!

No problem!

I used my credentials; I do not have admin access, but I shouldn't need it, should I?

No you don't need an account with admin - only if you are needing to perform user account changes such as password resets etc. I only use an account with read-only access in our domain.

For your configured LDAP_USERNAME - what username format are you using? You can only use either a userPrincipalName which will be in the format of user@domain.local or a full DistinguishedName which must be in the format of cn=John Doe,dc=domain,dc=local. You won't be able to authenticate with sAMAccountName's.

We are able to login in two different ways:

  1. Using just our usernames, e.g. jdoe
  2. Using our email addresses - I tried this by adding the email part as a suffix. E.g. jdoe@ad.blah.de, where "@ad.blah.de" is the suffix.

Neither of these ways worked.

I just spoke to someone from the admin team, who informed me of our DistinguishedName format: CN=Doe\,Jane, OU=User, UE=ad.blah.de, DC=ad, DC=blah, DC=de

But he also said that it would be better if I could use userPrincipalName instead, where I guess the format is: user@ad.blah.de

What do I need to do with this information? Sorry, I'm really new to this.

LetitiaJD commented 5 years ago

@stevebauman Okay, so I just managed to log in, but I'm not happy with the settings and I still don't know why it worked.

So in my .env file, my LDAP_USERNAME is in the form: jdoe@ad.blah.de.

Then in ldap.php, I have:

'account_prefix' => env('LDAP_ACCOUNT_PREFIX', ''),
'account_suffix' => env('LDAP_ACCOUNT_SUFFIX', ''),
'hosts' => explode(' ', env('LDAP_HOSTS', 'dc01.ad.blah.de dc02.ad.blah.de')),
'port' => env('LDAP_PORT', 389),
'base_dn' => env('LDAP_BASE_DN', 'DC=ad,DC=blah,DC=de'),
'username' => env('LDAP_USERNAME'),
'password' => env('LDAP_PASSWORD'),

But I want to be able to just use "jdoe" and not "jdoe@ad.blah.de". I tried adding "@ad.blah.de" and "ad.blah.de" (with and without the @ as I wasn't sure if it was appended automatically) to the LDAP_ACCOUNT_SUFFIX and then changed my LDAP_USERNAME to "jdoe", but it did not work.

stevebauman commented 5 years ago

Hey @LetitiaJD,

You’ll have to change your sync_attributes config options - namely the username key value. Change that to samaccountname instead of userprincipalname and you’ll be all set!

LetitiaJD commented 5 years ago

Hey @LetitiaJD,

You’ll have to change your sync_attributes config options - namely the username key value. Change that to samaccountname instead of userprincipalname and you’ll be all set!

I changed the sync_attributes config options in ldap_auth.php as suggested, but I am still unable to login with just my username "jdoe".

Do I need the suffix in ldap.php? What should the settings be?

stevebauman commented 5 years ago

Oh sorry, looking at your config, you’ll also have to set your ldap.locate_users_by value to samaccountname as well. You can leave both prefix and suffix blank.

You can also check your logs to see where it’s failing authentication.

Make that change above and let me know!

LetitiaJD commented 5 years ago

Oh sorry, looking at your config, you’ll also have to set your ldap.locate_users_by value to samaccountname as well. You can leave both prefix and suffix blank.

You can also check your logs to see where it’s failing authentication.

Make that change above and let me know!

I changed that and it's still failing. I looked at my log file but it always says the same thing: "Invalid credentials". Can I just confirm that in my .env file, I am meant to be using the LDAP_USERNAME as just jdoe and not jdoe@ad.blah.de, as that's how I want to log in?

[2019-05-08 10:43:22] local.INFO: LDAP (ldap://dc01.ad.blah.de:389 ldap://dc02.ad.blah.de:389) - Connection:  - Operation: Adldap\Auth\Events\Binding - Username: jdoe
[2019-05-08 10:43:22] local.WARNING: LDAP (ldap://dc01.ad.blah.de:389 ldap://dc02.ad.blah.de:389) - Connection:  - Operation: Adldap\Auth\Events\Failed - Username: jdoe - Reason: Invalid credentials
[2019-05-08 10:43:22] local.ERROR: Exception: Invalid credentials in /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php:104
Stack trace:
#0 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php(121): Adldap\Auth\Guard->bind('jdoe', 'XXXXX')
#1 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Connections/Provider.php(234): Adldap\Auth\Guard->bindAsAdministrator()
#2 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(106): Adldap\Connections\Provider->connect()
#3 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(67): Adldap\Laravel\AdldapServiceProvider->addProviders(Object(Adldap\Adldap), Array)
#4 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application), Ar$
#5 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#6 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\AdldapIn...', Array)
#7 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\AdldapIn...', Array)
#8 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapAuthServiceProvider.php(55): Illuminate\Foundation\Application->make('Adldap\\AdldapIn...')
#9 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapAuthServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application)$
#10 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#11 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\Laravel\\...', Array)
#12 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\Laravel\\...', Array)
#13 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(1225): Illuminate\Foundation\Application->make('Adldap\\Laravel\\...')
#14 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(175): Illuminate\Container\Container->offsetGet('Adldap\\Laravel\\...')
#15 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(144): Illuminate\Support\Facades\Facade::resolveFacadeInstance('Adldap\\Laravel\\...')
#16 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(231): Illuminate\Support\Facades\Facade::getFacadeRoot()
#17 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/Auth/DatabaseUserProvider.php(38): Illuminate\Support\Facades\Facade::__callStatic('byCredentials', Array)
#18 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(349): Adldap\Laravel\Auth\DatabaseUserProvider->retrieveByCredentials(Array)
#19 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(81): Illuminate\Auth\SessionGuard->attempt(Array, false)
#20 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(44): App\Http\Controllers\Auth\LoginController->attemptLogin(Object(Illuminate\Http\Request))
#21 [internal function]: App\Http\Controllers\Auth\LoginController->login(Object(Illuminate\Http\Request))
#22 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#23 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('login', Array)
#24 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\A$
#25 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#26 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#27 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /srv/htdocs/projects/returns/app/Http/Middleware/RedirectIfAuthenticated.php(24): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Requ$
#35 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure$
#36 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#44 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closu$
#45 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#52 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#53 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#54 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#55 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#56 /srv/htdocs/projects/returns/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#57 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#58 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#59 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#60 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#61 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#62 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#63 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#64 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#65 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Req$
#66 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closur$
#67 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#68 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\H$
#69 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object$
#70 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#71 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#72 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#73 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#74 /srv/htdocs/projects/returns/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#75 {main}

Next Adldap\Auth\BindException: Invalid credentials in /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php:109
Stack trace:
#0 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Auth/Guard.php(121): Adldap\Auth\Guard->bind('jdoe', 'XXXXXXX')
#1 /srv/htdocs/projects/returns/vendor/adldap2/adldap2/src/Connections/Provider.php(234): Adldap\Auth\Guard->bindAsAdministrator()
#2 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(106): Adldap\Connections\Provider->connect()
#3 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapServiceProvider.php(67): Adldap\Laravel\AdldapServiceProvider->addProviders(Object(Adldap\Adldap), Array)
#4 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application), Ar$
#5 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#6 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\AdldapIn...', Array)
#7 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\AdldapIn...', Array)
#8 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/AdldapAuthServiceProvider.php(55): Illuminate\Foundation\Application->make('Adldap\\AdldapIn...')
#9 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Adldap\Laravel\AdldapAuthServiceProvider->Adldap\Laravel\{closure}(Object(Illuminate\Foundation\Application)$
#10 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build(Object(Closure))
#11 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Adldap\\Laravel\\...', Array)
#12 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Container\Container->make('Adldap\\Laravel\\...', Array)
#13 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Container/Container.php(1225): Illuminate\Foundation\Application->make('Adldap\\Laravel\\...')
#14 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(175): Illuminate\Container\Container->offsetGet('Adldap\\Laravel\\...')
#15 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(144): Illuminate\Support\Facades\Facade::resolveFacadeInstance('Adldap\\Laravel\\...')
#16 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(231): Illuminate\Support\Facades\Facade::getFacadeRoot()
#17 /srv/htdocs/projects/returns/vendor/adldap2/adldap2-laravel/src/Auth/DatabaseUserProvider.php(38): Illuminate\Support\Facades\Facade::__callStatic('byCredentials', Array)
#18 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(349): Adldap\Laravel\Auth\DatabaseUserProvider->retrieveByCredentials(Array)
#19 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(81): Illuminate\Auth\SessionGuard->attempt(Array, false)
#20 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(44): App\Http\Controllers\Auth\LoginController->attemptLogin(Object(Illuminate\Http\Request))
#21 [internal function]: App\Http\Controllers\Auth\LoginController->login(Object(Illuminate\Http\Request))
#22 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#23 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('login', Array)
#24 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\A$
#25 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#26 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#27 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /srv/htdocs/projects/returns/app/Http/Middleware/RedirectIfAuthenticated.php(24): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Requ$
#35 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure$
#36 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#44 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closu$
#45 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#49 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#52 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#53 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#54 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#55 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#56 /srv/htdocs/projects/returns/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#57 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#58 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#59 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#60 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#61 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#62 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Re$
#63 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu$
#64 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#65 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Req$
#66 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closur$
#67 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#68 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\H$
#69 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object$
#70 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#71 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#72 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#73 /srv/htdocs/projects/returns/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#74 /srv/htdocs/projects/returns/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#75 {main}
LetitiaJD commented 5 years ago

@stevebauman I changed my LDAP_USERNAME value in .env to jdoe@ad.blah.de and then I was able to login with just jdoe :).

Thank you for your help!

stevebauman commented 5 years ago

Can I just confirm that in my .env file, I am meant to be using the LDAP_USERNAME as just jdoe and not jdoe@ad.blah.de, as that's how I want to log in?

No, this is the username of the user you are connecting to your AD server with first - it must be either the users full distinguished name (ex. cn=John Doe,dc=local,dc=com) or their user principal name (ex. jdoe@local.com).

This account is used for the initial connection to your AD server. Once that is successful, that account is used for authenticating your users into your Laravel application.

stevebauman commented 5 years ago

Awesome! Glad you were able to resolve it! :smile:

nspaul commented 5 years ago

I just wanted to reply to this lengthy thread and say that @stevebauman is an absolute hero. If we ever meet I owe you a drink

stevebauman commented 5 years ago

Thanks for your kind words @nspaul! Appreciate it 😄