I'm trying to extract values from an LDAP server. I've a very basic script to grab these using the following:
*** START ***
my $ldapconn = Net::LDAP->new($ldap{host},port => $ldap{port},version => $ldap{version}) or die "LDAP error: $@\n";
my $ldapbind = $ldapconn->bind($ldap{admin},password => $ldap{pass});
if ($ldapbind->code() != LDAP_SUCCESS){die "Error binding to LDAP: $ldapbind->error() if $ldapbind->code()";}
my $search = $ldapconn->search(
base => "ou=Users,dc=example,dc=com",
scope => "sub",
attrs => ['uid', 'userPassword'],
filter => '(radiusGroupName=vpn)'
);
my @vals = $search->attributes();
foreach my $val (@vals){print $val;}
*** END ***
But when I try to execute the script I get the following error:
Can't locate object method "attributes" via package "Net::LDAP::Search" at ./ex1.pl line 32, <DATA> line 225.
This also happens when trying:
my @vals = $search->get_value("userPassword");
Anyone see what I'm missing to get this to work?
Iain.
*** START ***
my $ldapconn = Net::LDAP->new($ldap{host},port => $ldap{port},version => $ldap{version}) or die "LDAP error: $@\n";
my $ldapbind = $ldapconn->bind($ldap{admin},password => $ldap{pass});
if ($ldapbind->code() != LDAP_SUCCESS){die "Error binding to LDAP: $ldapbind->error() if $ldapbind->code()";}
my $search = $ldapconn->search(
base => "ou=Users,dc=example,dc=com",
scope => "sub",
attrs => ['uid', 'userPassword'],
filter => '(radiusGroupName=vpn)'
);
my @vals = $search->attributes();
foreach my $val (@vals){print $val;}
*** END ***
But when I try to execute the script I get the following error:
Can't locate object method "attributes" via package "Net::LDAP::Search" at ./ex1.pl line 32, <DATA> line 225.
This also happens when trying:
my @vals = $search->get_value("userPassword");
Anyone see what I'm missing to get this to work?
Iain.