Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#15 | empty-string-2072033-15.patch | 446 bytes | cdmo |
#6 | ldap-do_not_empty_dn-2072033-6.patch | 1.21 KB | mikran |
#1 | 2072033-empty-ldap-attributes-not-removed.patch | 499 bytes | lawsonk |
Comments
Comment #1
lawsonk CreditAttribution: lawsonk commentedThe attached patch fixes the issue for me.
Comment #2
johnbarclay CreditAttribution: johnbarclay commentedThanks. 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?
Comment #3
lawsonk CreditAttribution: lawsonk commentedHmm. 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!
Comment #4
johnbarclay CreditAttribution: johnbarclay commentedThanks for the patch and for following up.
Comment #6
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedThis fix caused regression. The
dn
field is now always empty. Here's a fix for that.Comment #7
grahamtk CreditAttribution: grahamtk commented@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
Comment #8
grahlComment #9
grahlComment #14
grahlI 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.
Comment #15
cdmo CreditAttribution: cdmo commentedThe 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.
Comment #17
grahlHi
Thanks for the update, reopening is perfectly fine here since its the exact same problem.