Ciao!

I use Mozilla::LDAP::Conn quite successfully.  It's available from 
http://www.mozilla.org/directory/ as well as from CPAN.

Here's a snippet.  YMMV:

my %ld = Mozilla::LDAP::Utils::ldapArgs();

$ld{'host'} = 'some host';
$ld{'base'} = 'some base';

my $conn = Mozilla::LDAP::Conn->new(\%ld) ||
  die "Failed connection to LDAP server $ld{'host'}";

my (@rslts, @srch);

# Setup search criteria for query
push(@srch, 'cn=some data');

# Circulate through the search, fetching what matches.  Attribute list is fixed.
foreach my $search (@srch) {
  my $entry = $conn->search($ld{'root'}, $ld{'scope'}, "$search");

  # Check for search error(s)
  $conn->printError()
    if $conn->getErrorCode();

  # Found something.  See what it is
  while ($entry) {

    # Process the results here ... $entry is a hashref containing
    # keyed by your LDAP server attributes, whose values are anon
    # arrays
    @rslts = ($entry->{'cn'}[0]);

    $entry = $conn->nextEntry();
  }
}
$conn && $conn->close;

Peace.

Reply via email to