Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

NoDatabaseUserProvider - problems: 'samaccountname' key is missing from the given credentials array #903

Open
Vasiliy-Makogon opened this issue Nov 27, 2020 · 0 comments

Comments

@Vasiliy-Makogon
Copy link

  • Laravel Version: 6.0
  • Adldap2-Laravel Version: 6.0
  • PHP Version: 7.2
  • LDAP Type: ActiveDirectory

Description:

Hi. We are using AdLdap2 to log into ActiveDirectory via DatabaseUserProvider.

Users change passwords in ActiveDirectory, but the php application does not know about it and allows you to enter the user application under the old password.

I decided to use NoDatabaseUserProvider. Registered its configuration file ldap_auth.php.

I tried to log in and got this error: "Key 'samaccountname' is not present in the given credential array".

I've tried various options in the config file, but nothing comes out.

In our database, the user login is stored in the sys_login field, in AD, respectively, the field with the login samaccountname.

What am I doing wrong? File below:

'identifiers' => [

        /*
        |--------------------------------------------------------------------------
        | LDAP
        |--------------------------------------------------------------------------
        |
        | Locate Users By:
        |
        |   This value is the users attribute you would like to locate LDAP
        |   users by in your directory.
        |
        |   For example, using the default configuration below, if you're
        |   authenticating users with an email address, your LDAP server
        |   will be queried for a user with the a `userprincipalname`
        |   equal to the entered email address.
        |
        | Bind Users By:
        |
        |   This value is the users attribute you would
        |   like to use to bind to your LDAP server.
        |
        |   For example, when a user is located by the above attribute,
        |   the users attribute you specify below will be used as
        |   the 'username' to bind to your LDAP server.
        |
        |   This is usually their distinguished name.
        |
        */

        'ldap' => [

            'locate_users_by' => 'samaccountname',

            'bind_users_by' => 'distinguishedname',

        ],

        'database' => [

            /*
            |--------------------------------------------------------------------------
            | GUID Column
            |--------------------------------------------------------------------------
            |
            | The value of this option is the database column that will contain the
            | LDAP users global identifier. This column does not need to be added
            | to the sync attributes below. It is synchronized automatically.
            |
            | This option is only applicable to the DatabaseUserProvider.
            |
            */

            'guid_column' => 'objectguid',

            /*
            |--------------------------------------------------------------------------
            | Username Column
            |--------------------------------------------------------------------------
            |
            | The value of this option is the database column that contains your
            | users login username.
            |
            | This column must be added to your sync attributes below to be
            | properly synchronized.
            |
            | This option is only applicable to the DatabaseUserProvider.
            |
            */

            'username_column' => 'sys_login',

        ],

        /*
        |--------------------------------------------------------------------------
        | Windows Authentication Middleware (SSO)
        |--------------------------------------------------------------------------
        |
        | Local Users By:
        |
        |   This value is the users attribute you would like to locate LDAP
        |   users by in your directory.
        |
        |   For example, if 'samaccountname' is the value, then your LDAP server is
        |   queried for a user with the 'samaccountname' equal to the value of
        |   $_SERVER['AUTH_USER'].
        |
        |   If a user is found, they are imported (if using the DatabaseUserProvider)
        |   into your local database, then logged in.
        |
        | Server Key:
        |
        |    This value represents the 'key' of the $_SERVER
        |    array to pull the users account name from.
        |
        |    For example, $_SERVER['AUTH_USER'].
        |
        */

        'windows' => [

            'locate_users_by' => env('LDAP_USER_ATTRIBUTE', 'samaccountname'),

            'server_key' => 'AUTH_USER',

        ],

    ],
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant