jacksantho -3 Junior Poster

hi,

Please see my code as given below:

#!c:/perl/bin/perl
use strict;
use warnings;
use CGI qw(:all);    #use for all code
use Net::LDAP;
use Net::LDAP::Util qw(ldap_error_name
                       ldap_error_text); #use for Error Handling
print "Content-type: text/html\n\n";
print "<body bgcolor=\"#ffcccc\">";


my $entry;
my @uids;

my $serverlogin='administrator';
my $serverpassword='xxxxx';
my $LDAP_SERVER="localhost";
my $LDAP_PORT="389";

my $LDAP_BASE="ou=student,dc=ac,dc=in";

#INITIALIZING
my $ldap=Net::LDAP->new($LDAP_SERVER,port=>$LDAP_PORT) or die "Unable to connect to LDAP server $LDAP_SERVER: $@\n";




#BINDING

my $studentlogin='CE34';
my $studentpassword='c6';

my $binddn = "uid=$studentlogin, ou=student, dc=ac,dc=in";
my $result = $ldap->bind(uid => $binddn, password => $studentpassword,version=>3);
die $result ->error() if $result ->code();

my $mesg= $ldap->search(filter=>"(&(uid=$studentlogin)(objectClass=student))", 
                        base=>$LDAP_BASE);


if ($mesg->count()>0)
{
    print $mesg->count(),"entries returned.\n";
    foreach $entry($mesg->all_entries())
    {
         $entry->dump();
    }
}
print "</body>";
print "</html>";

and then try to get the dn (since nothing is returned, I'm guessing this is something that net::ldap doesn't return). My ldap search() is not returning any results. I don't know, whether my program is correct or not. Please help me out.Thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.