0 Replies - 610 Views - Last Post: 10 August 2015 - 01:49 PM

#1 RobertH332  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-August 15

[Perl] Trying to get users LDAP information.

Posted 10 August 2015 - 01:49 PM

Hey guys so Im trying to create a search in LDAP for getting a users information. This is what I have so far and when I run it it just returns COUNT 0. There are no errors. Im new to perl and ldap so any help or tips is greatly appreciated. Thanks for your help.

My Code:
  use strict;
  use warnings;
  
  use Net::LDAP;
  my $server = "[Server Address]";
  my $ldap = Net::LDAP->new( $server ) or die $@;
  $ldap->bind("[Username]", password => "[Password]");
  
  my $result = $ldap->search(
     base   => "CN=bb-ldaptest, OU=Security Groups, DC=cb, DC=careerbuilder, DC=com",
     filter => "(&(cn=[First Name]*) (sn=Last name*))",
 );
 
 die $result->error if $result->code;
 
 printf "COUNT: %s\n", $result->count;
 
 foreach my $entry ($result->entries) {
     $entry->dump;
 }
 print "===============================================\n";
 
 foreach my $entry ($result->entries) {
     printf "%s <%s>\n",
         $entry->get_value("member"),
         ($entry->get_value("mail") || '');
 }
 
 $ldap->unbind;



And the output is:
COUNT: 0
===============================================



Is This A Good Question/Topic? 0
  • +

Page 1 of 1