Hi ya'll,

I was hoping someone could shed some light on this problem I'm having with Net::LDAP. I'm trying to write a bit of perl code that does an LDAP search and returns, via STDOUT, the value of an attribute in the LDAP database. In this case, I want the value of "nisMapEntry" from within "cn=staff". Here is the code I wrote so far, which works:

use Net::LDAP;

my $ldap = Net::LDAP->new('ldap://ldapserver.mydomain.com/') or die "$@";

$ldap->bind;
#chomp $ARGV[0];

my $mount = $ldap->search(base => 'nisMapName=auto.home,dc=mydomain,dc=com',
                         filter => 'cn=staff');

$mount->code && die $mount->error;

foreach $entry ($mount->all_entries) {
    my $subloc = $entry->get_value('nisMapEntry');
    print "$subloc\n";
}

$ldap->unbind;

-----

What I CAN'T seem to do is replace 'cn=staff' with a variable, like 'cn=$ARGV[0]'. When I do that the search doesn't work. Maybe it's actually searching for the string '$ARGV[0]' instead of actually inserting the value of the variable there? Can anyone help me figure this out?

Thanks a million in advance!!

ciao, erich

Reply via email to