Yes now the metacharacter is the backslash, that perl wants to have doubled, if 
used as data, so try:

filter=> "( employeetype=consultant \\28pre-release\\29 )"

Cheers,

Peter



[EMAIL PROTECTED] schrieb:
Thanks for you help.

I tried this, but now I don't get any out put.  Not even an error message.





"Colbourn, Charles" <[EMAIL PROTECTED]> 09/27/2006 12:32 PM

To
<[EMAIL PROTECTED]>
cc

Subject
RE: Search filter problem






Hi,

according to the rfc, ( and ) are reserved characters (because they delimit clauses in the filter, the same is true of * because it's a wildcard).

change your filter to read ( employeetype=consultant \28pre-release\29 )

and it should work fine. \28 and \29 are the escapes for ( and ), \2a is the escape for * if you should need it.

regards,


charles.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 27 September 2006 17:22
To: perl-ldap@perl.org
Subject: Search filter problem


Hello all,

I am writing a simple search script using Net::LDAP.  The problem that I

am having is with the filter.

When I execute my script I get the following error message: "Bad filter
at line 15".

The attribute that I am use a part of the filter is "employeetype" and
the value is "consultant (pre-release)". This is a legitimate value.

I am able to retrieve the entries with the command line tool
"ldapsearch", but I am have trouble do it within my Net::LDAP script.

My code is below.

Thank you.


use Net::LDAP qw(:all);
use Net::LDAP::Util qw(ldap_error_text);

my $ldconnect = Net::LDAP->new('host', port=>'389') || die "$@";

my $sr = $ldconnect->search(
                                base=> 'O=com',
                                scope=> 'sub',
filter=> "( employeetype=consultant (pre-release) )"
);

 $sr->code && die "failed search: ", $sr->error ;

foreach my $entry ($sr->entries)
{
        $dn = $entry->dn;
        $cn = $entry->get_value('cn') || '-';
        $emp = $entry->get_value('employeetype') || '-';

        print "DN: $dn\n";
        print "Common Name: $cn\n";
        print "EMP Type: $emp\n";
}




--
_______________________________________________________________________

Peter Gietz (CEO)
DAASI International GmbH                   phone: +49 7071 2970336
Wilhelmstr. 106                            Fax:   +49 7071 295114
D-72074 Tübingen                           mail:  [EMAIL PROTECTED]
Germany                                    Web:   www.daasi.de

Directory Applications for Advanced Security and Information Management
_______________________________________________________________________


Reply via email to