Problems with comma inside RDN elements

Michael Ströder michael at stroeder.com
Mon Sep 29 21:56:17 CEST 2003


Jens Vagelpohl wrote:
> I have something where I am not sure whether the problem is in
> python-ldap or in my software. Calls to "search_s" hang when the RDN
> element contains a comma (escaped with backslash or not does not make a
> difference).
 > [..]
> res = conn.search_s(BASE, ldap.SCOPE_SUBTREE, 'member=%s' % MEMBER)

1. The parentheses for the filter template are missing.

2. Use ldap.filter.escape_filter_chars() for escaping the necessary 
back-slash and other chars special to filter strings (new in 2.0.0pre12).

res = conn.search_s(
   BASE,
   ldap.SCOPE_SUBTREE,
   '(member=%s)' % ldap.filter.escape_filter_chars(MEMBER)
)

OpenLDAP shouldn't hang though.

> cn=Doe, John,cn=Users,dc=as,dc=zope,dc=com

This is not a valid DN anyway.

Ciao, Michael.



More information about the python-ldap mailing list