Error : undefined function ldap_connect() in PHP


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()

$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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
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:


Easiest way to figure it out is to run phpinfo() - it'll tell you the path of the active php.ini file
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 ?
Dave BaldwinFixer of ProblemsCommented:
The first would be having an 'ldap' server to connect to.  Are you using the code on this page:

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?
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

prashanth agsoftware engineer Author Commented:
ldap_connect()' returning and  working fine ,

 but ldap_bind() shows warning :" Unable to bind to server: Can't contact LDAP server"
Dave BaldwinFixer of ProblemsCommented:
I suggest you try the demo code on 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Dave BaldwinFixer of ProblemsCommented:
Those values have to come from the LDAP server administrator.  Somebody who can give you access.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.