When using LDAP feeds to synchronize a set of attributes from AD to Drupal we discovered that attributes that had their values deleted in AD were not removed from the Drupal user object. For example removing a user's department in AD would not delete the department in the Drupal user object so the Drupal user ID still ends up displaying the old department.

PHP's "ldap_get_entries()" doesn't return an array value for attributes that are blank so when the LDAP entry gets to ldap_feeds there's nothing there to be processed and feeds doesn't modify the attribute value in the user object.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lawsonk’s picture

johnbarclay’s picture

Thanks. I committed this. I changed:
$parsed_item[$source] = ' ';

to

$parsed_item[$source] = '';

Is there are reason you wanted a single space instead of an empty string?

lawsonk’s picture

Hmm. Not sure what I was thinking with the space. Just tested $parsed_item[$source] = ''; against department field in our dev environment and I can confirm it's working as expected. Removing a department from the AD user now results in the row in the field_data_field_department table being deleted.

Thanks!

johnbarclay’s picture

Status: Needs review » Fixed

Thanks for the patch and for following up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mikran’s picture

This fix caused regression. The dn field is now always empty. Here's a fix for that.

grahamtk’s picture

@johnbarclay @mikran
I tested this patch in #6. it worked on our live site importing employees from our university administrative system, but I had to have a space character like @lawsonk :

$parsed_item[$source] = ' ';
to
$parsed_item[$source] = '';

Without the space character the value would keep the old value. probably feeds checks '' as empy and discards it? I dont know why, but here, it worked only with the space char. I have a failry up to date drupal 7 site with regularly updated modules.

Cheers.
Øyvind

grahl’s picture

Status: Needs review » Needs work
grahl’s picture

Status: Needs work » Needs review

The last submitted patch, 1: 2072033-empty-ldap-attributes-not-removed.patch, failed testing.

The last submitted patch, 1: 2072033-empty-ldap-attributes-not-removed.patch, failed testing.

The last submitted patch, 1: 2072033-empty-ldap-attributes-not-removed.patch, failed testing.

  • grahl committed 5ebfe01 on 7.x-2.x authored by mikran
    Issue #2072033 by lawsonk, mikran: LDAP Feeds: Empty LDAP attributes...
grahl’s picture

Status: Needs review » Fixed

I don't like breaking the loop but I don't see any side-effect so I'm committing this with the space character based on the #7 feedback. Please reopen if insufficient.

cdmo’s picture

The empty string changing to a string with a space broke functionality with the release of 7.x-2.x-beta12. I had views setup to fallback (no results behavior) to a value if empty - those all broke. Patch attached to fix this.

Please advise if I was supposed to report this in a separate issue, not sure on protocol.

  • grahl committed 7af772a on 7.x-2.x authored by cdmo
    Issue #2072033 by mikran, cdmo: LDAP Feeds: Empty LDAP attributes that...
grahl’s picture

Status: Needs review » Fixed

Hi

Thanks for the update, reopening is perfectly fine here since its the exact same problem.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.