DirectoryTree / LdapRecord-Laravel

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

[Question] php artisan ldap:import #648

Closed hakihosting closed 7 months ago

hakihosting commented 7 months ago

Environment:

Describe the bug: when i launch php artisan ldap:import i have this error : Provider [ldap] does not exist.

stevebauman commented 7 months ago

Hi @hakihosting,

This error means you do not have a provider named ldap inside of your config/auth.php file. Try using:

php artisan ldap:import users

If you still receive an error, please make sure you've followed the configuration steps in the documentation here:

https://ldaprecord.com/docs/laravel/v3/auth/database/configuration

hakihosting commented 7 months ago

Hello thank you for the command i try it :) it works but i have this message. Allowed memory size of 134217728 bytes exhausted (tried to allocate 221184 bytes)

stevebauman commented 7 months ago

Hi @hakihosting,

Please try the --chunk option mentioned here to prevent memory issues:

https://ldaprecord.com/docs/laravel/v3/auth/database/importing/#chunk

hakihosting commented 7 months ago

Thanks but i have another problem : Call to undefined method App\Models\User::getLdapGuidColumn()

stevebauman commented 7 months ago

Hi @hakihosting,

Please add the AuthenticatesWithLdap trait onto your App\Models\User model:

// ...
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;

class User extends Authorizable
{
    // ...
    use AuthenticatesWithLdap;
}

Then re-run the import again.

hakihosting commented 7 months ago

I do the change when i launch the command i have this log : Would you like these users to be imported / synchronized? (yes/no) [yes]:

y

1/1 [============================] 100% Successfully imported / synchronized [0] user(s).

Why 0 users

hakihosting commented 7 months ago

But nothing it imported or synchronized

stevebauman commented 7 months ago

Hi @hakihosting,

Check your base_dn in your LDAP configuration to ensure it's properly set to the root of your domain.

Besides that, this is something you'll have to investigate further, as I don't have access to your environment to debug.

hakihosting commented 6 months ago

It works but it not syncronized or imported :

PS C:\Users\p4479562\PhpstormProjects\5344 - Mydesk> php artisan ldap:import users neji
Found user [CN=Heyckel NEJI].

Would you like to display the user(s) to be imported / synchronized? (yes/no) [no]:

y

+-----------------------------------------------------------------------------+--------------------+ | Name | Distinguished Name | +-----------------------------------------------------------------------------+--------------------+ | CN=Heyckel NEJI,OU=Telemat,OU=Internal,OU=Users,OU=PZBN,DC=ZPZ5344,DC=local | CN=Heyckel NEJI | +-----------------------------------------------------------------------------+--------------------+

Would you like these users to be imported / synchronized? (yes/no) [yes]:

y

1/1 [============================] 100% Successfully imported / synchronized [0] user(s). PS C:\Users\p4479562\PhpstormProjects\5344 - Mydesk>

Aut.php

'users' => [ 'driver' => 'ldap', 'model' => LdapRecord\Models\ActiveDirectory\User::class, 'rules' => [], 'database' => [ 'model' => App\Models\User::class, 'sync_passwords' => true, 'sync_attributes' => [ 'name' => 'sAMAccountName', 'email' => 'mail', ], 'sync_existing' => [ 'name' => 'sAMAccountName', 'email' => 'mail', 'guid' => 'guid', 'domain' => 'domain', ], ],

    ],
stevebauman commented 6 months ago

Hi @hakihosting,

If importing fails, please check the storage/logs directory in your application and read the last printed exceptions, as it will display the cause of failure.

hakihosting commented 6 months ago

Hello i have look the log : Failed importing object [Heyckel NEJI]. SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicata du champ

So the recors already exist in the table but i would like to syncronized it but they don't to because they already exist. How i can syncronized it if the date exist.

hakihosting commented 6 months ago

Ok i found :) now i can syncronized. The field password is the same paswoord set on the AD ?

hakihosting commented 6 months ago

I think when it s imported they create a new password , is not the password in the AD.

stevebauman commented 6 months ago

I think when it s imported they create a new password , is not the password in the AD.

Yes this is correct: https://ldaprecord.com/docs/laravel/v3/auth/database/importing/#password-synchronization

hakihosting commented 6 months ago

Ok and how can i do for the login.The user set the email and the password of AD.How can i do that ?Envoyé à partir de Outlook pour Android

hakihosting commented 6 months ago

Some response ?