hi,

I have a problem querying the intranet LDAP database of my company with information about all the computer users. Using the example page from the perl-ldap home page, I created a small script, that attaches to the database, and does a query using different bases.

It appears that only one branch of the directory is shown to script (see output) and that the script is not able to retreive the schema.
I have put the script and the output at the end of this mail.


Has anybody had this situation before? Any hints or pointers are welcome!
Thanks in advance,

Ruud




======================script #!/usr/bin/perl -w

use warnings;
use strict;

use Net::LDAP qw(:all);
use Net::LDAP::Schema;

my $ldap = new Net::LDAP('srv011gv.abc.nl')
   || die "Could not connect to LDAP server: [EMAIL PROTECTED]";
my $mesg = $ldap->bind (version => 3 );          # use for searches

my $schema = $ldap->schema ();
foreach ($schema->all_objectclasses ())
{ print "..\n"; }

my $filter = "cn=*";
my $attrs = ['distinguishedName'];
$attrs = ['cn'];
my @bases = (
'DC=abc,DC=nl',
'OU=ict, DC=abc, DC=nl',
'CN=Users,DC=abc,DC=nl',
"CN=Configuration,DC=abc,DC=nl",
);

foreach my $b (@bases)
{
       print STDERR "=========================\n";
       query ($ldap, $b, $filter, $attrs);
}

$mesg = $ldap->unbind; # take down session

sub query
{
       my ($ldap, $base, $filter, $attrs) = @_;

       print STDERR "query with base [$base] and filter [$filter]\n";
       my $msg = $ldap->search(
       base  => "$base",
       scope => "sub",
       filter => $filter,
       attrs => $attrs,
   );

       print STDERR "number of hits: " . $msg->count () . "\n";
       $msg->code () && die $msg->error;

my $href = $msg->as_struct;

        # get an array of the DN names
        my @arrayOfDNs  = keys %$href;        # use DN hashes

        # process each DN using it as a key
        foreach ( @arrayOfDNs ) {
          print $_, "\n";
        }
}

======================output (explanation: in the first three queries, the DN's are valid and should produce output; when I query with base [CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl] I get the same 16 entries as below)

=========================
query with base [DC=abc,DC=nl] and filter [cn=*]
number of hits: 0
=========================
query with base [OU=ict, DC=abc, DC=nl] and filter [cn=*]
number of hits: 0
=========================
query with base [CN=Users,DC=abc,DC=nl] and filter [cn=*]
number of hits: 0
=========================
query with base [CN=Configuration,DC=abc,DC=nl] and filter [cn=*]
number of hits: 16
CN=Proxy,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Authenticated Users,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Creator Group,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=System,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Creator Owner,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Terminal Server User,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Network,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Everyone,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Enterprise Domain Controllers,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Dialup,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Service,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Self,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Interactive,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Restricted,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Anonymous Logon,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl
CN=Batch,CN=WellKnown Security Principals,CN=Configuration,DC=abc,DC=nl


_________________________________________________________________
MSN Search, for accurate results! http://search.msn.nl



Reply via email to