Hi,
Please check my code :
[B]#!c:/perl/bin/perl
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
use Net::LDAP qw(LDAP_SUCCESS LDAP_PROTOCOL_ERROR);
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";
#INITIALIZING
my $ldap=Net::LDAP->new($LDAP_SERVER,port=>$LDAP_PORT) or die "Could not create LDAP object because:\n$!";
#BINDING
my $mesg=$ldap->bind(version=>3); #use for searches
$mesg=$ldap->bind("$userDN",password=>"$PASSWORD",version=>3);
#SEARCHING
my $ldapSearch=$ldap->search(
base=>$LDAP_BASE,
filter=>"uid1=$USERNAME");
if ($ldapSearch->code)
{
print "ERROR detected: -> ",
ldap_error_name($ldapSearch->code), " ",
ldap_error_text($ldapSearch->code);
warn "ERROR - not LDAP_SUCCESS";
}
my $total = $ldapSearch->count;
print " the total is $total";
print "</body>";
print "</html>";
[/B]
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.:(