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.
Comments
Comment #2
grahlThanks 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.
Comment #3
lbesenyei commentedSure, so the DN looks like this>
CN=1elek.teszt,CN=Users,DC=csy,DC=spaceand after running ldapEscapeDn() (with ldap_escape function) it looks like this:
CN\3d1elek.teszt\2cCN\3dUsers\2cDC\3dcsy\2cDC\3dspaceComment #5
grahlHi
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.
Comment #7
grahlNo feedback, presuming that this fixed it.
Please reopen if this introduces a regression for someone else.