jotaelesalinas / laravel-adminless-ldap-auth

Authenticate users in Laravel against an adminless LDAP server
MIT License
210 stars 33 forks source link

PHP Notice: Undefined index: user_format in /vendor/jotaelesalinas/laravel-adminless-ldap-auth/src/LdapHelper.php on line 21 #43

Closed Nuvelle closed 4 years ago

Nuvelle commented 4 years ago

Detailed description

When using Tinker to test the Auth (as described in the Usage part of the readme) the above notice is thrown:

C:\Users\me\PhpstormProjects\project>php artisan tinker
Psy Shell v0.10.4 (PHP 7.4.6 — cli) by Justin Hileman
>>> Auth::Guest()
PHP Notice:  Undefined index: user_format in C:/Users/me/PhpstormProjects/project/vendor/jotaelesalinas/laravel-adminless-ldap-auth/src/LdapHelper.php on line 21
=> true
>>>

Line 21:

        $this->user_full_dn_fmt = $config['identifiers']['ldap']['user_format'];

My identifiers are the default options at this stage whilst testing:

'ldap' => [

            'locate_users_by' => 'userprincipalname',

            'bind_users_by' => 'distinguishedname',

        ],

Your environment

Include as many relevant details about the environment you experienced the bug in and how to reproduce it.

github-actions[bot] commented 4 years ago

Hi #! Welcome to this repo.

jotaelesalinas commented 4 years ago

Looks like you forgot to add user_format to ldap_auth.identifiers.ldap: https://github.com/jotaelesalinas/laravel-adminless-ldap-auth#configure-the-ldap-authentication-in-configldap_authphp. Try creating it and let me know.

Nuvelle commented 4 years ago

That did it, any reason it is not there by default when the other 2 entries were?

jotaelesalinas commented 4 years ago

I'm glad you solved it! This variable is not in ldap_auth.php by default because it is not needed by the Adldap package. I think I will move this config variable outside this file in the future.