Adldap2 / Adldap2-Laravel

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

Can't import an user #464

Closed pmirandaarias closed 6 years ago

pmirandaarias commented 6 years ago

Description: I use the command php artisan adldap:import someemail, everything goes well, it found the user, then I put yes, yes. Then the last message is Successfully imported / synchronized 0 user(s).

Why is not importing the user? My provider is:

'provider' => Adldap\Laravel\Auth\DatabaseUserProvider::class,

pmirandaarias commented 6 years ago

adldap_auth.php:

connection' => env('ADLDAP_CONNECTION', 'default'),
    'provider' => Adldap\Laravel\Auth\DatabaseUserProvider::class,
    'resolver' => Adldap\Laravel\Auth\Resolver::class,
    'importer' => Adldap\Laravel\Auth\Importer::class,
    'rules' => [
        Adldap\Laravel\Validation\Rules\DenyTrashed::class,
    ],
    'scopes' => [
        Adldap\Laravel\Scopes\UpnScope::class,
    ],
    'usernames' => [
        'ldap' => 'administrador',
        'eloquent' => 'email',
    ],
    'login_fallback' => env('ADLDAP_LOGIN_FALLBACK', false),
    'password_sync' => env('ADLDAP_PASSWORD_SYNC', true),
    'windows_auth_attribute' => ['samaccountname' => 'AUTH_USER'],
    'sync_attributes' => [
        'email' => 'userprincipalname',
        'name' => 'cn',
    ],

adldap.php

'connections' => [
    'default' => [
        'auto_connect' => true,
        'connection' => Adldap\Connections\Ldap::class,
        'schema' => Adldap\Schemas\ActiveDirectory::class,
        'connection_settings' => [
            'account_prefix' => env('ADLDAP_ACCOUNT_PREFIX', ''),
            'account_suffix' => env('ADLDAP_ACCOUNT_SUFFIX', '@redXXX.XXX.cl'),
            'domain_controllers' => explode(' ', env('ADLDAP_CONTROLLERS', 'X.X.X.X')),
            'port' => env('ADLDAP_PORT', 389),
            'timeout' => env('ADLDAP_TIMEOUT', 5),
            'base_dn' => env('ADLDAP_BASEDN', 'dc=redXXX,dc=XXX,dc=cl'),
            'admin_account_suffix' => env('ADLDAP_ADMIN_ACCOUNT_SUFFIX', '@redXXX.XXX.cl'),
            'admin_username' => env('ADLDAP_ADMIN_USERNAME', 'administrador'),
            'admin_password' => env('ADLDAP_ADMIN_PASSWORD', 'XXX'),
            'follow_referrals' => false,
            'use_ssl' => false,
            'use_tls' => false,
        ],
    ],
],
stevebauman commented 6 years ago

Hi, can you check your log? All users who can't be imported are logged with the exception.

pmirandaarias commented 6 years ago

Which log? Adldap log? or php, mysql

stevebauman commented 6 years ago

The Laravel log file stored in your applications storage directory.

pmirandaarias commented 6 years ago

2018-01-24 13:33:16] production.ERROR: Unable to import user Alonso Arriagada Aguayo. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'field list' (SQL: insert into users (email, name, password, updated_at, created_at) values (aarriagada@redcne.cne.cl, Alonso Arriagada Aguayo, $2y$10$GTKVp.6aqny6ugA7r/qBKeMiMz6zP3H4rw3uYn0t2CDnvKUBNkZqK, 2018-01-24 13:33:16, 2018-01-24 13:33:16))

pmirandaarias commented 6 years ago

meh... I'm using "Laravel-boilerplate"... and the users table is like this:

image

pmirandaarias commented 6 years ago

Should I say goodbye to Adldap2? :( I need to connect to LDAP with this system...

stevebauman commented 6 years ago

Looks like your users table doesn't have a name column and you're syncing a name column in your sync_attributes.

stevebauman commented 6 years ago

The exception is clear on your issue, this isn't an Adldap2 problem, this is a configuration issue.

pmirandaarias commented 6 years ago

In that case, should I try to adding to

'sync_attributes' => [

    'email' => 'userprincipalname',
    'name' => 'cn',

],

The rest of attributes that I have on my table?

stevebauman commented 6 years ago

If you don't want your users to have a name, then you need to remove the name key in your sync_attributes array.

pmirandaarias commented 6 years ago

got it, it works. Thanks.

jonathan-bird commented 6 years ago

To anyone looking back on this, you could technically just change name key in sync_attributes array to:

'first_name' => 'givenname',
'last_name'=>'sn',