ldap search is failing with error "Bad search filter (-7)" for complex search filter having spaces in OpenLDAP 2.6.7
venugopal chinnakotla <[email protected]> Fri, 17 Oct 2025 16:54:25 +0530
| Newsgroups | gmane.network.openldap.technical,gmane.network.openldap.devel |
|---|---|
| Message-ID | <CAJCMw6sEvq_4g+gUziVpnmC-tK7z+PA7=89fHaUPqodmf-0+DQ@mail.gmail.com> |
--000000000000866e04064158fab1 Content-Type: text/plain; charset="UTF-8" Hi Team, We are working on migration of nsldap C sdk to OpenLDAP C sdk for our application client code. We are using OpenLDAP 2.6.7. As part of this migration, we are facing one issue with a search filter that we are using to get content from LDAP servers. search filter: (| (uid=user1) (| ([email protected]) (! (mail= [email protected]) ) ) ) We are using this search filter for user lookup from LDAP servers in our application for one of our cases. We are using OpenLDAP C API: ldap_search_ext_s (and/or ldap_search_ext) in our application. When we make a search call from our application to LDAP server using the above search filter, we are getting "Bad search filter (-7)" error instead of the users list. Due to this, our migration is blocked. Tried using the same search filter with *ldapsearch *utility provided by OpenLDAP, but getting the same error message. Below is the snippet of error with search filter. *>ldapsearch.exe -H ldap://ldapserver1.com:389 <http://ldapserver1.com:389> -D "cn=admin,o=test.com <http://test.com>" -b o=test.com <http://test.com> "(| (uid=user1) (| ([email protected] <[email protected]>) (! ([email protected] <[email protected]>) ) ) )"# extended LDIF## LDAPv3# base <o=test.com <http://test.com>> with scope subtree# filter: (| (uid=user1) (| ([email protected] <[email protected]>) (! ([email protected] <[email protected]>) ) ) )# requesting: ALL#ldap_search_ext: Bad search filter (-7)* But the same search filter is working fine with our existing nsldap provider. We are able to get the users list from the LDAP server using the same search filter without any changes. To maintain backward compatibility in our application, we should be able to get the content from the LDAP server using the same search filter. Could you please look into this problem and provide a solution for this? -- Thanks, *c.venugopal* --000000000000866e04064158fab1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hi Team,<br><br>We are working on migration of nsldap= C sdk to OpenLDAP C sdk for our application client code.<br><br>We are usi= ng OpenLDAP 2.6.7.</div><div><br></div><div>As part of this migration, we a= re facing one issue with a search filter that we are using to get content f= rom LDAP servers.</div><div><br></div><div>search filter:=C2=A0(| (uid=3Dus= er1) (| (mail=3D<a href=3D"mailto:[email protected]">[email protected]</a>) (! (m= ail=3D<a href=3D"mailto:[email protected]">[email protected]</a>) ) ) )</div>= <div><br></div><div><br></div><div>We are using this search filter for user= lookup from LDAP servers in our application for one of our cases.</div><di= v>We are using OpenLDAP C API:=C2=A0ldap_search_ext_s (and/or=C2=A0ldap_sea= rch_ext) in our application. When we make a search=C2=A0call from our appli= cation to LDAP server using the above search=C2=A0filter, we are getting &q= uot;Bad search filter (-7)" error instead of the users=C2=A0list. Due = to this, our migration is blocked. Tried using the same search=C2=A0filter = with <b>ldapsearch=C2=A0</b>utility provided by OpenLDAP, but getting the s= ame error message. Below is the snippet of error with search filter.</div><= div><br></div><div><i>>ldapsearch.exe -H ldap://<a href=3D"http://ldapse= rver1.com:389">ldapserver1.com:389</a> -D "cn=3Dadmin,o=3D<a href=3D"h= ttp://test.com">test.com</a>" -b o=3D<a href=3D"http://test.com">test.= com</a> "(| (uid=3Duser1) (| (mail=3D<a href=3D"mailto:[email protected]"= >[email protected]</a>) (! (mail=3D<a href=3D"mailto:[email protected]">user100= @test.com</a>) ) ) )"<br># extended LDIF<br>#<br># LDAPv3<br># base &l= t;o=3D<a href=3D"http://test.com">test.com</a>> with scope subtree<br># = filter: (| (uid=3Duser1) (| (mail=3D<a href=3D"mailto:[email protected]">user1= @test.com</a>) (! (mail=3D<a href=3D"mailto:[email protected]">[email protected]<= /a>) ) ) )<br># requesting: ALL<br>#<br><br>ldap_search_ext: Bad search fil= ter (-7)</i></div><div><br></div><div>But the same search filter is working= fine with our existing nsldap provider. We are able to get the users list = from the LDAP server using the same search filter without any changes. To m= aintain backward compatibility=C2=A0in our application, we should be able t= o get the content from the LDAP server using the same search=C2=A0filter.</= div><div><br></div><div>Could you please look into this problem and provide= a solution for this?</div><div><br></div><div><br></div><span class=3D"gma= il_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signatur= e" data-smartmail=3D"gmail_signature"><div><font style=3D"background-color:= #ffffff">Thanks,</font></div> <div><em><strong><font color=3D"#006600">c.venugopal</font></strong></em></= div></div></div> --000000000000866e04064158fab1--