use Net::LDAP; use strict; my $id ='1234'; my $ldap = Net::LDAP->new('host','port') or die "$@"; $ldap->bind; my $mesg = $ldap->search (base => $base, filter => "employee_number=$id", attrs => [firstname,lastname,employee_number,department,city]); my %userinfo; foreach my $entry ($mesg->entries){ foreach my $attr ($entry->attributes){ $userinfo{$attr} = $entry->get($attr); } #$entry->dump; # saw it in the examples but no docs! } # test the hash... foreach my $attr (keys %userinfo){ print "$attr\t$userinfo{$attr}\n"; } $ldap->unbind;