BigJoe has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone been able to get Net::LDAP on winNT?
I have pasted together this script
#!/usr/bin/perl use Net::LDAP qw(:all); $ldap = Net::LDAP->new('pluto') or die "$@"; $ldap->bind; # an anonymous bind my $base = "c=us"; my @Attrs = (); my $gettem = "harnish"; $result = LDAPsearch($ldap,"sn=" . $gettem,\@Attrs); @entries = $result->entries; foreach $entr (@entries) { $phone = $entr->get_value('telephoneNumber'); $user = $entr->get_value('cn'); $email = $entr->get_value('mail'); print "$user\n"; print "$email\n"; print "$phone\n"; } undef @selected; $ldap->unbind; # take down session sub LDAPsearch { my ($ldap,$searchString,$attrs) = @_ ; my $result = $ldap->search ( base => "$base", scope => "sub", filter => "$searchString", attrs => $attrs, sizelimit => $size_limit ); }
This works fine on Linux RH7 but on winNT it errors on the "$entr->get_value" so I remove the _value and run it. On both systems it gives me this output:
ARRAY(0x1f6b378) ARRAY(0x1f6aa70) ARRAY(0x1f6ad7c)
Any Ideas? Thanks

--BigJoe

Learn patience, you must.
Young PerlMonk, craves Not these things.
Use the source Luke.

Replies are listed 'Best First'.
Re: Net::LDAP on NT
by chromatic (Archbishop) on Dec 15, 2000 at 04:37 UTC
    Disclaimer: I'm by no means an LDAP guru, but I've read up on it.

    Net::LDAP and Mozilla::LDAP both seem to store entry values in anonymous arrays. (A DN can have multiple values, like in the 'phones' field.) My documentation suggests $entr->get(), but doesn't mention that that returns the anonymous array.

    In any case, I suspect something like:

    ($phone) = @{ $entr->get('telephoneNumber') }; ($user) = @{ $entr->get('cn') }; ($email) = @{ $entr->get('mail') };
    would do more what you want. Another approach would be to add $phone = $phone->[0]; after the get() call.
      YOU ARE AWESOME. It worked perfectly. Thanks

      --BigJoe

      Learn patience, you must.
      Young PerlMonk, craves Not these things.
      Use the source Luke.