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\thesis\auth.php on line 21
Expand|Select|Wrap|Line Numbers
- <?php
- session_start();
- echo $_POST['security_code'];
- $userid=$_POST['userid'];
- #echo $userid;
- $password=$_POST['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=$_SERVER['SCRIPT_NAME'];
- if ( ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) && (isset($userid)) && (isset($password)))
- {
- $filter="CN=$userid";
- #$filter="(&(|(!(displayname=Administrator*))(!(displayname=Admin*)))(cn=$username))";
- //define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(administrator should be renamed anyway!).
- $dn = "CN=$userid";
- if (!($connect = ldap_connect($server))) {
- exit(0);
- }
- echo" after second connect";
- if (!($bind = ldap_bind($connect,"$dn,"."$basedn",$password)))
- {
- #header("Location:newlog.php");
- exit(0);
- }
- echo" after second bind";
- $sr = ldap_search($connect, $basedn,$filter);
- $info = ldap_get_entries($connect, $sr);
- if(!$sr)
- {
- #header("Location:newlog.php");
- print "<br>anonymous search failed";
- exit(0);
- }
- if($info["count"] == 0)
- {
- #header("Location:newlog.php");
- print "<br>User unknown";
- exit(0);
- }
- if($info["count"] > 1)
- {
- #header("Location:newlog.php");
- print "<br>More than one such user - report to CITS";
- exit(0);
- }
- #$fullname=$info[0]["displayname"][0];
- $fullname=$info[0]["givenname"][0]." ".$info[0]["sn"][0];
- echo $fullname;
- # $fqdn=$info[0]["dn"];
- #echo $fqdn;
- echo "<br>";
- $id =$info[0]["telephonenumber"][0];
- echo $id;
- echo "<br>";
- $mail= $info[0]["userprincipalname"][0];
- echo $mail;
- echo "<BR>";
- print_r($_SERVER[SERVER_ADDR]);
- $d=date("Y-m-d H:i:s");
- echo "<BR>";
- #echo $d;
- setcookie("cookie[user]",$userid);
- setcookie("cookie[token]",$password);
- setcookie("cookie[fullname]",$mail);
- setcookie("cookie[fqdn]", $id);
- # header("Location:traffic.php");
- } else {
- #header("Location:error.php");
- die();
- }
- ?>