in reply to ldapsearch in perl
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ldapsearch in perl
by jose_m (Acolyte) on Jan 08, 2013 at 15:04 UTC | |
by jose_m (Acolyte) on Jan 09, 2013 at 15:28 UTC |