Closed pbauer closed 5 years ago
It works when it is like this:
from Products.CMFPlone.utils import safe_unicode
def safe_encode(val):
return safe_unicode(val).encode('utf-8')
For reference, here is a screenshot of the corresponding attributes:
Hi,
the problem is not the safe_encode function, but the binary attribute not listed as such in node.ext.ldap.
Schould be fixed via https://github.com/bluedynamics/node.ext.ldap/commit/15cf2988be07f97a00c37714666739448370e19b
If you encounter similar problems with other attributes/schemas, check whether attributes are declared as binary attributes and define them here https://github.com/bluedynamics/node.ext.ldap/blob/master/src/node/ext/ldap/properties.py#L14
Please let me know if the commit fixes your problem, then I'll drop a release. Thanks.
Thanks! I had the feeling that is was a issue in node.ext.ldap. I still think that safe_encode
should always return jsonable data, otherwise it is not really 'safe' :wink:
Also: objectGUID
is also binary and missing in https://github.com/bluedynamics/node.ext.ldap/commit/15cf2988be07f97a00c37714666739448370e19b
Excellent! We'll try that soon and get back to you.
I have tried pas.plugins.ldap 1.5.3 with node.ext.ldap 1.0b7 and it is still broken:
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module pas.plugins.ldap.plonecontrolpanel.inspector, line 50, in node_attributes
Module node.ext.ldap._node, line 457, in node_by_dn
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)
It happens when the dn contains special characters (á, ñ, etc.)
@dmunicio thanks, this bug belongs to node.ext.ldap. May you be so kind and provide a ldif example snippet?
Sorry I can't provide ldiff example because the users are real and that information is confidential. This is an example of the URL : http://mydomain.local/@@plone_ldapnodeattributes?dn=CN%3DSurname1+Fern%C3%A1n%5C%2C+Jose%2COU%3DMyBuilding%2COU%3DMyCity%2COU%3DUserss%2COU%3DMyDepartment%2CDC%3DMyOrg%2CDC%3Dlocal&base=users&_=0123456789012
When inspecting the data for the following user (that is
node.attrs.items()
):I get a traceback because of the values in
objectGUID
andobjectSid
:The method
safe_encode
seems to need some improving.