Error : undefined function ldap_connect() in PHP

Hi,

When i am attempting to use ldap_connect(),  and I follow these steps before to connect

1•      c:\wamp\php\php.ini In this file uncomment the line: extension=php_ldap.dll
2•      Move the file: libsasl.dll, from c:\wamp\php to [Your Drive]:\wamp\apache\bin
3•      Restarted Apache.

but it shows  

Fatal error: Call to undefined function ldap_connect()



session_start();
$user1='admin';
$ldaprdn = $user1 . DIRECTORY_SEPARATOR . $_POST['Username'];
$_SESSION['username'] =$_POST['Username'];
$ldappass = $_POST['password'];
// connect to ldap server 
$ldapconn = ldap_connect("leavemanagement") 

Open in new window

prashanth agsoftware engineer Asked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
I suggest you try the demo code on http://php.net/manual/en/function.ldap-bind.php with known good username and password to see if the service is actually available.  I tried to set up an LDAP server on my Ubuntu system but haven't succeeded yet.  One of the issues is that the standard port is 389 and it was not being allowed thru the firewall.
0
 
Chris StanyonCommented:
I think you're probably editing the wrong php.ini file. In a standard WAMP setup, the php.ini file that's used is the one in the /bin folder of your Apache folder, something like this:

C:\wamp24\bin\apache\apache2.4.4\bin\php.ini

Easiest way to figure it out is to run phpinfo() - it'll tell you the path of the active php.ini file
0
 
prashanth agsoftware engineer Author Commented:
Searched  libeay32.dll and ssleay32.dll(C:\WINDOWS\system32) copied  in the same path(i.,e C:\wamp\bin\php\php5.4.16\ext).
added that path to the system path and restarted   wamp The problem is solved  



but i get new error message

Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in



if ($ldapconn) { 

    // binding to ldap server 
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass) or die(); 

    // verify binding 
    if ($ldapbind)

Open in new window


what are prerequisites to connect ldap in php ?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Dave BaldwinFixer of ProblemsCommented:
The first would be having an 'ldap' server to connect to.  Are you using the code on this page:  http://php.net/manual/en/function.ldap-bind.php

Is 'ldap_connect()' returning without error? Above you have...
$ldapconn = ldap_connect("leavemanagement") 

Open in new window

That is odd for a URL.  If that is a local server, maybe DNS is not working for that name.  Try the IP address?
0
 
prashanth agsoftware engineer Author Commented:
Yes
ldap_connect()' returning and  working fine ,

 but ldap_bind() shows warning :" Unable to bind to server: Can't contact LDAP server"
0
 
prashanth agsoftware engineer Author Commented:
what is ldap rdn  and associated password what i need to pass for both variable '$ldaprdn','$ldappass'
 
$ldaprdn  = 'uname';     // ldap rdn or dn
$ldappass = 'password';  // associated password
0
 
Dave BaldwinFixer of ProblemsCommented:
Those values have to come from the LDAP server administrator.  Somebody who can give you access.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.