Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Why is this not working?

Im trying to get a list of available entries from ldap by simple filter: attribute cn must be less than 1000 and greater than 500. According to Net::LDAP documentation this could be done like this:

#!/usr/bin/env perl use strict; use warnings; use Net::LDAP; my $ldap = Net::LDAP->new('192.168.9.111'); my $mesg = $ldap->bind('cn=root,dc=lomonosov,dc=parallel,dc=ru', passw +ord => 'rootpw'); $|=1; print "Searching for uids less than 1000 and gt 500... "; $mesg = $ldap->search( base => "ou=slurm,dc=lomonosov,dc=parallel,dc=ru", filter => "&(cn<=1000)(cn>=500)" ); $mesg->code && die $mesg->error; print "Ok\nFound: "; print join ", ", map $_->get_value("cn"), $mesg->entries;
But it produces:
Searching for uids less than 1000 and gt 500... Ok Found:
I know that there is a two hundred or so entries in ldap for this request,
fisher% ldapsearch -h 192.168.9.111 -D "cn=root,dc=lomonosov,dc=parall +el,dc=ru" -w "rootpw" -b "ou=slurm,dc=lomonosov,dc=parallel,dc=ru" "& +(cn>600)(cn<1000)" |tail -3 # numResponses: 145 # numEntries: 144
In fact, the problem experienced on a simple filters with 'less than' or 'greater than' comparisions; complex search filters like '|(cn=527)(cn=528)' works just fine. What am I doing wrong? How can I get a list of entries with said filter?

Answer found, thanks to all. The original request using ldapsearch was wrong (according to rfc4515 there isn't '<' sign but '<='); the server doesn't answer for that type of comparisions becouse of absence of index.


In reply to Net::LDAP q by fisher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found