bad filter

Michael Ströder michael at stroeder.com
Thu Jul 1 18:05:05 CEST 2010


Anil wrote:
> I pass a filter string such as this to search(), but I keep getting
> BAD SEARCH FILTER error.
> "(|(last-login-time<=100101*)(!(last-login-time=*)))"

Using <= with * in the assertion value looks bogus to me.

> The same thing works when using it with ldapsearch command.

Does not work for me when using OpenLDAP's ldapsearch:

$ ldapsearch "(|(last-login-time<=100101*)(\!(last-login-time=*)))"
ldapsearch: ldap_search_ext: Bad search filter (-7)

Note the extra back-shlash needed before ! since ! is a special char
for the shell.

> I also
> tried running it through ldap.filter.escape_filter_chars.

You should not pass complete filter strings to
ldap.filter.escape_filter_chars(). This function should only be used for the
assertion values you put into the filter string afterwards.

> Is this a known bug?

Nope.

Ciao, Michael.


More information about the python-ldap mailing list