Hello Jose , You need to bind to the ldap server from there on , and use the count method to get the number of entries . Try including the below piece of code inside your subroutine,changing the $ldapserver to point to each of your hosts . The filter filter => "(objectClass=*)" , will get all of the entries Hope this helps !!!
#!/usr/bin/perl use Net::LDAP; my $ldapserver = "<Server Name>"; my $ldapbase = "ou=people,ou=Urania,ou=Eng,dc=example,dc=com"; my $ldap = Net::LDAP->new( $ldapserver ) or die "$@"; my $mesg = $ldap->bind("cn=user>,ou=people,ou=Urania,ou=Eng,dc=example +,dc=com", password=>'<user>'); $mesg = $ldap->search( base => $ldapbase, filter => "(objectClass=*)") +; my @entries = $mesg->count; print "@entries\n"; $mesg = $ldap->unbind;
In reply to Re: ldapsearch in perl
by ravi6289
in thread ldapsearch in perl
by jose_m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |