Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LDAP interaction

Status
Not open for further replies.

perld

ISP
Oct 21, 2005
5
0
0
MT
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.
 
According to the doc on CPAN, the search method returns a Net::LDAP::Search object, which doesn't appear to have an 'attributes' or a 'get_value' method...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top