Problem with LDAP search filter containing a backslash ('\')
Clément OUDOT <[email protected]> Wed, 20 Jul 2011 11:02:33 +0200
| Newsgroups | gmane.comp.lang.perl.modules.ldap |
|---|---|
| Message-ID | <CAK_oV49F9_Uu8nhjHiyi-9SmayGpqn2dT1LOe8WrXQMLagD4WA@mail.gmail.com> |
Hi,
I have a piece of code where I build a search filter with some
variables, like this:
my $searchFilter =
"(&(objectClass=" . $portal->{ldapGroupObjectClass} . ")(|";
foreach ( split( $portal->{multiValuesSeparator}, $value ) ) {
$searchFilter .= "(" . $key . "=" . $_ . ")";
}
$searchFilter .= "))";
This works well, excepted when the value (in the key=value syntax)
contains a backslash ('\'). This is the case for example if the value
is a DN like this : cn=OUDOT\, Clement, ou=users, dc=example, dc=com
To make this works, I added this line :
$searchFilter =~ s/\\/\\\\/;
My question: is this a bug in my code, or can this be a Perl-LDAP bug?
I am using version 0.4001.
Thanks for your help,
Clément OUDOT
http://lemonldap-ng.org