From: Jens V. <je...@zo...> - 2003-09-29 18:05:10
|
Hi Michael (and whoever else is still listening ;) 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). Here's a simple test script that I am using against a server here:: conn = ldap.initialize('ldap://my.ldap.server') conn.set_option(ldap.VERSION, ldap.VERSION3) conn.simple_bind_s(ADMIN, PASSWD) res = conn.search_s(BASE, ldap.SCOPE_SUBTREE, 'member=%s' % MEMBER) conn.unbind_s() It works fine for "normal" RDN elements, such as when MEMBER looks like this:: cn=Jens Vagelpohl,cn=Users,dc=as,dc=zope,dc=com but it hangs completely with these MEMBERs:: cn=Doe\, John,cn=Users,dc=as,dc=zope,dc=com cn=Doe, John,cn=Users,dc=as,dc=zope,dc=com I am working with python-ldap version 2.0.0pre13, running on OS X 10.2.6 against the built-in OpenLDAP libraries (it is not exactly clear which exact OpenLDAP version these are). This is probably not a OS-dependent problem because I am coming against it reproducing it for someone else. Any pointers welcome - maybe I just need to escape that comma differently? jens |
From: <mi...@st...> - 2003-09-29 19:56:54
|
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. |
From: Jens V. <je...@zo...> - 2003-09-29 20:12:48
|
> 1. The parentheses for the filter template are missing. Yup, I know. I was just testing all kinds of combinations just to force some kind of solution :) > 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). I see the module inside the source package, but it never gets put anywhere by distutils from what I can tell. "ldap.filter" gives me an AttributeError. > res = conn.search_s( > BASE, > ldap.SCOPE_SUBTREE, > '(member=%s)' % ldap.filter.escape_filter_chars(MEMBER) > ) I'll try as soon as the filter module is in place 8-) > OpenLDAP shouldn't hang though. The query itself was against a M$ CraptiveDirectory server. I found myself unable to force a record like that into OpenLDAP... hehe >> cn=Doe, John,cn=Users,dc=as,dc=zope,dc=com > > This is not a valid DN anyway. Yup, I know :) jens P.S.: Today I realized that I must have been unsubscribed from the list for quite a while. I just thought it had gotten really quiet... |
From: <mi...@st...> - 2003-09-29 20:21:01
|
Jens Vagelpohl wrote: > >> 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). > > I see the module inside the source package, but it never gets put > anywhere by distutils from what I can tell. "ldap.filter" gives me an > AttributeError. You're right. It was fixed in CVS some weeks ago. :-/ revision 1.54 date: 2003/08/20 20:27:10; author: stroeder; state: Exp; lines: +2 -1 Added ldap.filter to py_modules > P.S.: Today I realized that I must have been unsubscribed from the list > for quite a while. I just thought it had gotten really quiet... It was really low-traffic indeed. Ciao, Michael. |
From: <mi...@st...> - 2003-09-29 20:17:19
|
Michael Str=F6der wrote: >=20 > 2. Use ldap.filter.escape_filter_chars() for escaping the necessary=20 > back-slash and other chars special to filter strings (new in 2.0.0pre12= ). Or even better use ldap.filter.filter_format(). res =3D conn.search_s( BASE, ldap.SCOPE_SUBTREE, ldap.filter.filter_format( '(member=3D%s)',(MEMBER,) ) ) Ciao, Michael. |
From: Jens V. <je...@zo...> - 2003-09-29 21:12:23
|
> Or even better use ldap.filter.filter_format(). > > res = conn.search_s( > BASE, > ldap.SCOPE_SUBTREE, > ldap.filter.filter_format( > '(member=%s)',(MEMBER,) > ) > ) This is great and solves the original problem. The only problem I am finding is that if I happen to have a wildcard filter such as... (objectClass=*) or (cn=*jens*) the replacement of '*' with r'\2a' seems problematic. I'm not getting the expected results, as a maatter of fact I am not getting any results. jens |