User sync to LDAP server does not seem to work if the LDAP PHP extension is enabled, resulting in the following watchdog error:

Could not update entry "CN\3d1elek.teszt\2cCN\3dUsers\2cDC\3dcsy\2cDC\3dspace": Invalid DN syntax.

Tracked down the issue to the \Drupal\ldap_servers\LdapTransformationTraits::ldapEscapeDn method.
If we don't have ldap extension enabled, this function escapes only these 4 characters: '*', '\\', '(', ')'. NOT including '=', and ','.

As a result with LDAP PHP extension enabled, with the escaped '=' and ',' characters updating the ldap entry fails.

As a workaround I have implemented the hook_ldap_entry_pre_provision_alter hook, to recreate the entry with correct DN.

CommentFileSizeAuthor
#5 3099265-5-remove-escaping.patch1005 bytesgrahl

Comments

lbesenyei created an issue. See original summary.

grahl’s picture

Thanks for the bug report, could you please add the DN as it should be (escaped as well as unescaped)? That would make testing easier and I can check with the RFC. It might also be an issue how we use the trait in that context.

lbesenyei’s picture

Sure, so the DN looks like this> CN=1elek.teszt,CN=Users,DC=csy,DC=space
and after running ldapEscapeDn() (with ldap_escape function) it looks like this: CN\3d1elek.teszt\2cCN\3dUsers\2cDC\3dcsy\2cDC\3dspace

  • grahl committed 958c840 on 8.x-4.x
    Issue #3099265: User sync to LDAP not working with ext-ldap
    
grahl’s picture

Status: Active » Needs review
StatusFileSize
new1005 bytes

Hi

So the trait was wrong in how it escaped things, I've add the symfony polyfill as a dependency to make this now fail consistently.

You should now get the same error with or without the extension.

Can you please try the attached patch and see if it solves your problem against latest DEV? Also could you please share how you have defined the DN in the LDAP mapping? The code there is concerned with compound tokens so I want to make sure I'm not breaking those.

  • grahl committed d421c04 on 8.x-4.x
    Issue #3099265 by grahl: User sync to LDAP not working with ext-ldap
    
grahl’s picture

Status: Needs review » Fixed

No feedback, presuming that this fixed it.

Please reopen if this introduces a regression for someone else.

Status: Fixed » Closed (fixed)

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