473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

LDAP authentication

18
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\thesis\auth.php on line 21
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. echo $_POST['security_code'];
  4. $userid=$_POST['userid'];
  5. #echo $userid;
  6. $password=$_POST['password'];
  7. $server="10.2.0.12";        //change to ip address of ldap server
  8. $basedn="OU=EDU,DC=academic,DC=aua,DC=am";       //change to reflect the ou and domain that your users are in.
  9. #$script=$_SERVER['SCRIPT_NAME'];
  10.  
  11.  
  12.  
  13.  
  14.                 if ( ($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) && (isset($userid)) && (isset($password))) 
  15.                 {
  16.  
  17.                      $filter="CN=$userid";
  18.                         #$filter="(&(|(!(displayname=Administrator*))(!(displayname=Admin*)))(cn=$username))"; 
  19.                                //define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(administrator should be renamed anyway!).
  20.                         $dn = "CN=$userid";
  21.                                 if (!($connect = ldap_connect($server))) {
  22.                                         exit(0);
  23.                                 }
  24.                                  echo" after second connect";
  25.                                 if (!($bind = ldap_bind($connect,"$dn,"."$basedn",$password)))
  26.                                  {
  27.                                     #header("Location:newlog.php");
  28.  
  29.                                       exit(0);
  30.                                 }
  31.  
  32.                                   echo" after second bind";
  33.                 $sr = ldap_search($connect, $basedn,$filter);
  34.                 $info = ldap_get_entries($connect, $sr);
  35.                 if(!$sr)
  36.     {    
  37.  
  38.         #header("Location:newlog.php");
  39.         print "<br>anonymous search failed";
  40.         exit(0);
  41.     }
  42.     if($info["count"] == 0)
  43.     {   
  44.         #header("Location:newlog.php");
  45.         print "<br>User unknown";
  46.         exit(0);
  47.     }
  48.     if($info["count"] > 1)
  49.     {
  50.         #header("Location:newlog.php");
  51.         print "<br>More than one such user - report to CITS";
  52.         exit(0);
  53.     }
  54.                 #$fullname=$info[0]["displayname"][0];
  55.                 $fullname=$info[0]["givenname"][0]." ".$info[0]["sn"][0];
  56.                 echo $fullname;
  57.                # $fqdn=$info[0]["dn"];
  58.                 #echo $fqdn;
  59.  
  60.                 echo "<br>";
  61.                 $id =$info[0]["telephonenumber"][0];
  62.                 echo $id;
  63.                 echo "<br>";
  64.                 $mail= $info[0]["userprincipalname"][0];
  65.                 echo $mail;
  66.                 echo "<BR>";
  67.               print_r($_SERVER[SERVER_ADDR]);
  68.                   $d=date("Y-m-d H:i:s");
  69.                   echo "<BR>";
  70.                   #echo $d;
  71.                 setcookie("cookie[user]",$userid);
  72.                 setcookie("cookie[token]",$password);
  73.                 setcookie("cookie[fullname]",$mail);
  74.                 setcookie("cookie[fqdn]", $id);
  75.                # header("Location:traffic.php");
  76.         } else {
  77.        #header("Location:error.php");
  78.         die();
  79. }
  80. ?>
Jul 21 '07 #1
3 3868
mwasif
802 Expert 512MB
Call to undefined function ldap_connect()
you need to enable LDAP support.
Jul 21 '07 #2
pbmods
5,821 Expert 4TB
Akkad, please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page the next time you post.
Jul 21 '07 #3
to enable ldap in you'r php :

all you have to do is to uncomment the line :
extension=php_ldap.dll
in the php.ini file .


to know more about using ldap in php , type read user permissions in the search field in forum page , and you will find solutions we got , see the one posted by me (hamarsheh).

good luck!
Jul 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: dmcconkey | last post by:
Hi folks, I've been searching for a while and haven't found my specific question anywhere else. If this has already been asked, please accept my appologies and point me to the appropriate...
0
by: Ronald Wunderlich | last post by:
Hi, My first Question: can db2 (db2ckpw) ask over pam_ldap my edirectory ldap server for user authentication? The scenario: 1. computer suse linx enterprise server 8(SLES8) and edirectory...
3
by: mrwoopey | last post by:
Hi, I am using the example "Authenticate against the Active Directory by Using Forms Authentication and Visual Basic .NET": http://support.microsoft.com/default.aspx?scid=KB;EN-US;326340 ...
1
by: Serge | last post by:
Good Day Folks, I'm still trying to write a class to do LDAP searches on a Novell eDirectory. I've yet to see anything that even compiles, this includes samples from MSDN. Amazing. I...
6
by: Notgiven | last post by:
I am considering a large project and they currently use LDAP on MS platform. It would be moved to a LAMP platform. OpenLDAP is an option though I have not used it before. I do feel fairly...
4
by: Terry Miller | last post by:
I have DB2 V8.2 loaded on a Redhat Enterprise Linux version 3 (RHEL 3) box. RHEL is configured to talk to LDAP for authenticaton besides the local passwd file. I can verify this by executing an su...
2
by: duncan beaumont | last post by:
Hi, - SQLserver 2000 - Yellowfin 2.4 - Windows 2003 server I have been asked to investigate seting up LDAP authentication to access our Yellowfin reporting.
0
by: jayadevi | last post by:
Is it possible to configure an IIS to do both LDAP authentication and Windows authentication? For ex: Suppose one application of server A is hosted in IIS. The requests come from two different...
3
by: RJN | last post by:
Hi I've written a code that queries Windows LDAP server and works fine, but the same doesn't work when querying Solaris LDAP server. DirectoryEntry de = new...
1
by: jesbuddy07 | last post by:
Hello, I'm using IIS 5 and PHP 4.3.5. I have an html page, page1, that resides at member.company.com server. It contains a form asking a user to login. I then check the login by connecting to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.