Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#7 Binary values not escaped

closed
None
5
2006-11-16
2005-05-01
Mark Hammond
No

We are using python-ldap to talk to a Windows Active
Directory server, and trying to query for the
objectGUID attribute.

This attribute contains binary data, but that data is
not escaped by ldap.filter.escape_filter_chars.

The existing code takes RFC2254 quite literally.
However, the RFC also states "Other characters besides
the ones listed above may be escaped using this
mechanism, for example, non-printing characters."

The following implementation of escape_filter_chars
seems to solve this problem and still conform to the RFC.

def escape_filter_chars(assertion_value):
"""
Replace all special characters found in assertion_value
by quoted notation
"""
r = []
for c in assertion_value:
if c < '0' or c > 'z' or c in "\\*()":
c = "\\%02x" % ord(c)
r.append(c)
return ''.join(r)

Discussion

    • status: open --> pending
     
    • status: pending --> open
     
  • Logged In: YES
    user_id=64920
    Originator: NO

    ldap.filter.escape_filter_chars() has new a key-word argument escape_mode=0 now.

    escape_mode
    If 0 only special chars mentioned in RFC 2254
    are escaped.
    If 1 all NON-ASCII chars are escaped.
    If 2 all chars are escaped.

    Please test.

     
    • assigned_to: nobody --> stroeder
    • status: open --> closed