Re: Problem with LDAP search filter containing a backslash ('\')

[email protected] (Chris Ridd)
Newsgroups perl.ldap
Message-ID <[email protected]>
On 20 Jul 2011, at 13:12, Clément OUDOT wrote:

> And what about doing this:
> 
> $filter = Net::LDAP::Filter::_escape( $filter );
> 
> Would this work?
> 

That's an internal method used to escape assertion values. If you run it on the whole filter string it will also escape the other characters that are special in LDAP search filter strings.

eg: Net::LDAP::Filter::_escape("(cn=foo)") returns '\28cn=foo\29'.

That is because "(" and ")" are special characters.

So you can't usefully run it on the entire filter string. You *could* run it on each assertion value you're using, with the caveat that it isn't a public supported method.

Graham, should _escape be made public? It seems like it would be useful. Or is manipulating the data structure returned from new the better approach?

Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.