jacksantho -3 Junior Poster

Please check my code :

use strict;
use Carp;
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\">";
print "hi";

my $login="domain\username";
my $passwd="mrbkks";

my $USERNAME=$login;
my $PASSWORD=$passwd;
my $LDAP_SERVER="servername";
my $LDAP_PORT="389";

my $LDAP_BASE="ou=student,dc=univ,dc=ac,dc=in";
my $userDN="uid1=$USERNAME,ou=student,dc=univ,dc=ac,dc=in";

my $ldap=Net::LDAP->new($LDAP_SERVER,port=>$LDAP_PORT) or die "Could not create LDAP object because:\n$!";

my $mesg=$ldap->bind(version=>3); #use for searches

my $ldapSearch=$ldap->search(

if ($ldapSearch->code) 
 print "ERROR detected: -> ",
 ldap_error_name($ldapSearch->code), " ",
 warn "ERROR - not LDAP_SUCCESS";
my $total = $ldapSearch->count;
print " the total is $total";
print "</body>";
print "</html>";

While running this program in my web server Apache, in Error Log its showing an error message:
ERROR detected:LDAP_OPERATIONS_ERROR(1) Server Encountered an internal error.

Its binding correctly, not showing any errors, but while in ldap->search, i am facing this error. I don't know, how to rectify this problem. Please check my code. I don't know, to sort out my errors.:(

Be a part of the DaniWeb community

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