srini.here has asked for the wisdom of the Perl Monks concerning the following question:

below is my ldap search query  $ldap->search(base=>$ldapbase, scope => "sub", filter=>"(cn= John Wyner (DRAFT))");

in the above code, (DRAFT) is part of the full search name. The query doesn't work. But it does work for all the search names that don't have parantheses. I tried several things like escaping the brackets, giving Johy Wyner*. The latter gives me all results having John Wyner not the one in DRAFT team. It's clear that parantheses are being considered part of the ldap syntax and not the cn value. Any ideas?

Replies are listed 'Best First'.
Re: LDAP. Parantheses present in the filter cn value
by shmem (Chancellor) on Dec 05, 2013 at 15:35 UTC

    Escaping them with a backslash (within double quotes the backslash is meaningful and must be escaped, so two of them) should work:

    $ldap->search( base => $ldapbase, scope => "sub", filter => "(cn= John Wyner \\(DRAFT\\))" );
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      If shmem's suggestion does not work for you, then you may want to look at (untested) replacing the parens in question with their hex representations per RFC 4514, so the string becomes "(cn = John Wyner \64DRAFT\65)".

      Hope that helps.

      thanks a ton. that did help. :) :) :)