I have looked at the documentation with Net::LDAP and have been able to come up with the following solution so far. This seems kind of clunky to me and I would really like to find a better way to use the information returned from the LDAP search.
use Net::LDAP; $id='1234'; $ldap = Net::LDAP->new($host,$port) or die "$@"; $ldap->bind; $mesg = $ldap->search (base => $base, filter => "employee_number=$id", attrs => [firstname,lastname,employee_number,department,ci +ty]); my $max = $mesg->count; # put into a local hash for later use... for($i=0;$i<$max;$i++){ my $entry = $mesg->entry($i); foreach my $attr($entry->attributes){ my $printstring = join("\| ",$attr, $entry->get($attr)); my ($attrkey,$attrvalue) = split(/\|/,$printstring); $userinfo{$attrkey}=$attrvalue; } } # test the hash... foreach $key(keys %userinfo){ print "$key\t $userinfo{$key}\n"; }
In reply to Is there a better solution: data from Net::LDAP? by mrmick
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |