Hey All,
I am working on a perl script to do some LDAP stuff and am running into an issue with my attrs LDAP value.
Here is my current subroutine that is giving me issues:
Code:
sub get_name_by_uid {
my ($ldap, $userid, $base) = @_;
my @Attrs = ();
my $mesg = $ldap->search (
base => $base,
attrs => [givenName, sn],
filter => "(uid=$userid)" );
if ($mesg->code == 0) {
my $entry = $mesg->entry(0);
if ($entry) {
return $entry;
}
else {
return undef;
}
}
else {
return undef;
}
}
sub ldap_bind {
my ($host, $dn, $password) = @_;
my $ldap = Net::LDAP->new($host);
my $mesg = $ldap->bind ($dn, password => $password);
return $ldap if ($mesg->code == 0);
return undef;
}
The error that I am getting is related to barewords in my attrs line on the get_name_by_uid subroutine:
Bareword "givenName" not allowed while "strict subs" in use at ./test.pl line 60, <DATA> line 522.
Bareword "sn" not allowed while "strict subs" in use at ./test.pl line 60, <DATA> line 522.
I can't seem to find a solution to this and am not a perl expert by any means.
I am trying to setup my subroutine to do an LDAP search with the $userid which is provided as an option to the script and return the givenName and sn LDAP attributes.
Thanks for any help you can provide!