hi every body.
my question is : how to authenticate with LDAP server from the localhost (WAMP) ?
coz when i am trying to authenticate using the same code that i have on the linux server (working perfectly) it is giving me the following error message:
Fatal error: Call to undefined function ldap_connect() in C:\wamp\www\the sis\auth.php on line 21
[code=php]
<?php
session_start() ;
echo $_POST['security_code'];
$userid=$_POST['userid'];
#echo $userid;
$password=$_POS T['password'];
$server="10.2.0 .12"; //change to ip address of ldap server
$basedn="OU=EDU ,DC=academic,DC =aua,DC=am"; //change to reflect the ou and domain that your users are in.
#$script=$_SERV ER['SCRIPT_NAME'];
if ( ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSI ON['security_code'])) && (isset($userid) ) && (isset($passwor d)))
{
$filter="CN=$us erid";
#$filter="(&(|( !(displayname=A dministrator*)) (!(displayname= Admin*)))(cn=$u sername))";
//define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(a dministrator should be renamed anyway!).
$dn = "CN=$userid ";
if (!($connect = ldap_connect($s erver))) {
exit(0);
}
echo" after second connect";
if (!($bind = ldap_bind($conn ect,"$dn,"."$ba sedn",$password )))
{
#header("Locati on:newlog.php") ;
exit(0);
}
echo" after second bind";
$sr = ldap_search($co nnect, $basedn,$filter );
$info = ldap_get_entrie s($connect, $sr);
if(!$sr)
{
#header("Locati on:newlog.php") ;
print "<br>anonym ous search failed";
exit(0);
}
if($info["count"] == 0)
{
#header("Locati on:newlog.php") ;
print "<br>User unknown";
exit(0);
}
if($info["count"] > 1)
{
#header("Locati on:newlog.php") ;
print "<br>More than one such user - report to CITS";
exit(0);
}
#$fullname=$inf o[0]["displaynam e"][0];
$fullname=$info[0]["givenname"][0]." ".$info[0]["sn"][0];
echo $fullname;
# $fqdn=$info[0]["dn"];
#echo $fqdn;
echo "<br>";
$id =$info[0]["telephonenumbe r"][0];
echo $id;
echo "<br>";
$mail= $info[0]["userprincipaln ame"][0];
echo $mail;
echo "<BR>";
print_r($_SERVE R[SERVER_ADDR]);
$d=date("Y-m-d H:i:s");
echo "<BR>";
#echo $d;
setcookie("cook ie[user]",$userid);
setcookie("cook ie[token]",$password );
setcookie("cook ie[fullname]",$mail);
setcookie("cook ie[fqdn]", $id);
# header("Locatio n:traffic.php") ;
} else {
#header("Locati on:error.php");
die();
}
?>[/code]
my question is : how to authenticate with LDAP server from the localhost (WAMP) ?
coz when i am trying to authenticate using the same code that i have on the linux server (working perfectly) it is giving me the following error message:
Fatal error: Call to undefined function ldap_connect() in C:\wamp\www\the sis\auth.php on line 21
[code=php]
<?php
session_start() ;
echo $_POST['security_code'];
$userid=$_POST['userid'];
#echo $userid;
$password=$_POS T['password'];
$server="10.2.0 .12"; //change to ip address of ldap server
$basedn="OU=EDU ,DC=academic,DC =aua,DC=am"; //change to reflect the ou and domain that your users are in.
#$script=$_SERV ER['SCRIPT_NAME'];
if ( ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSI ON['security_code'])) && (isset($userid) ) && (isset($passwor d)))
{
$filter="CN=$us erid";
#$filter="(&(|( !(displayname=A dministrator*)) (!(displayname= Admin*)))(cn=$u sername))";
//define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(a dministrator should be renamed anyway!).
$dn = "CN=$userid ";
if (!($connect = ldap_connect($s erver))) {
exit(0);
}
echo" after second connect";
if (!($bind = ldap_bind($conn ect,"$dn,"."$ba sedn",$password )))
{
#header("Locati on:newlog.php") ;
exit(0);
}
echo" after second bind";
$sr = ldap_search($co nnect, $basedn,$filter );
$info = ldap_get_entrie s($connect, $sr);
if(!$sr)
{
#header("Locati on:newlog.php") ;
print "<br>anonym ous search failed";
exit(0);
}
if($info["count"] == 0)
{
#header("Locati on:newlog.php") ;
print "<br>User unknown";
exit(0);
}
if($info["count"] > 1)
{
#header("Locati on:newlog.php") ;
print "<br>More than one such user - report to CITS";
exit(0);
}
#$fullname=$inf o[0]["displaynam e"][0];
$fullname=$info[0]["givenname"][0]." ".$info[0]["sn"][0];
echo $fullname;
# $fqdn=$info[0]["dn"];
#echo $fqdn;
echo "<br>";
$id =$info[0]["telephonenumbe r"][0];
echo $id;
echo "<br>";
$mail= $info[0]["userprincipaln ame"][0];
echo $mail;
echo "<BR>";
print_r($_SERVE R[SERVER_ADDR]);
$d=date("Y-m-d H:i:s");
echo "<BR>";
#echo $d;
setcookie("cook ie[user]",$userid);
setcookie("cook ie[token]",$password );
setcookie("cook ie[fullname]",$mail);
setcookie("cook ie[fqdn]", $id);
# header("Locatio n:traffic.php") ;
} else {
#header("Locati on:error.php");
die();
}
?>[/code]
Comment