DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

[Bug] No users returnd by ldap:import #613

Closed jfoucher closed 7 months ago

jfoucher commented 7 months ago

Environment:

Describe the bug:

When I launch the command php artisan ldap:import All I get in return is There were no users found to import. When I know for a fact that the LDAP server contain users (I used Apache Directory Studio to make sure.)

When I use php artisan ldap:browse, I can see the users just fine, and php artisan ldap:testgives me a successful connection

What could be going wrong? Thanks

jfoucher commented 7 months ago

I tried with both an OpenLDAP server running in docker, and the forumsys.com one.

jfoucher commented 7 months ago

As an FYI, I fixed it by changing the configured model in my auth.php config file

I had this

    'providers' => [
        'users' => [
            ...
        ],

        'ldap' => [
            'driver' => 'ldap',
            'model' => LdapRecord\Models\ActiveDirectory\User::class,
            'rules' => [],
            'database' => [
                'model' => App\Models\User::class,
                'sync_passwords' => true,
                'sync_attributes' => \App\Ldap\AttributeHandler::class,
                'sync_existing' => [
                    'email' => 'mail',
                ],
            ],
        ],
    ],

I replaced the 'model' line with

'model' => LdapRecord\Models\OpenLDAP\User::class,

and now the import works fine.