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

Sync_attributes not filling NULL's in DB on adldap:import #620

Closed
TipTopNick opened this issue Nov 14, 2018 · 1 comment
Closed

Sync_attributes not filling NULL's in DB on adldap:import #620

TipTopNick opened this issue Nov 14, 2018 · 1 comment

Comments

@TipTopNick
Copy link

  • Laravel Version: 5.7.13
  • Adldap2-Laravel Version: 5.0.0
  • PHP Version: 7.2.2
  • LDAP Type: ActiveDirectory

In my ldap_auth.php I have some (as an example)
sync_attributes => ['email'=>'mail', 'address' => 'streetaddress' ],
which use to work just fine when doing php artisan adldap:import to get my users table populated. If a user did NOT have an email or address it would leave a NULL for that field in the database.

After updating to Adldap2-Laravel 5.0.0, if the email or address was NULL it now puts in the string 'mail' for email or 'streetaddress' for address in my database if the LDAP field is NULL. Any idea what is going on?

For now a work around I've used is ... in my 'sync_attributes' => ['email => ('mail' == 'mail') ? NULL : 'mail'] and so on for every field in sync_attributes that can contain a NULL.

@stevebauman
Copy link
Member

stevebauman commented Nov 14, 2018

Hi @TipTopNick,

This was an unlisted change in the upgrade guide, you can see this here:

https://github.com/Adldap2/Adldap2-Laravel/blob/v5.0.0/src/Commands/Import.php#L133

This was added to allow the use of raw values (such as booleans, integers and strings) during a sync. If the value on the LDAP users model is null, (as you described) then the true value is used.

For example, you can set a user attribute on your Eloquent model named from_ad to indicate if the user has been synchronized from ActiveDirectory:

'sync_attributes' => [
    'email' => 'mail',
    'address' => 'streetaddress',
    'from_ad' => true,
],

To resolve this issue right now, you can use an Attribute Handler, but this is something I want to patch. I'm unsure how I could handle both situations with how the sync attribute array is currently set up.

Any thoughts?

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

No branches or pull requests

2 participants