PHP Fatal error: Call to undefined function: ldap_connect()

Posted on 2004-11-08
Last Modified: 2013-12-13
I keep getting a fatal error with my LDAP connect to Active Directory.  This should be a no brainer but I'm at a loss...

I have a phone book written in PHP.  It calls on a function file.  This use to work and the guy who coded this left the company.  I used a couple of editing programs and still can't figure it out...  I replace real server IP with a fake one & fake account info.  Here's the code:


# define action constants
define( INITIALIZE, 0 );
define( SEARCH, 1 );

function connect_to_server() {

      $ldaphost = "";
      $ldapport = 389;
      $ldaprdn = '';
      $ldappass = 'password';

      $ds=ldap_connect($ldaphost ,$ldapport)
            or die("Cannot connect to {$ldaphost}");
      if ($ds) {
            // binding to ldap server
            $ldapbind = ldap_bind($ds, $ldaprdn, $ldappass)
                  or die("LDAP bind failed...");
      return $ds;


Any help would be appreciated!  I need to have this fixed ASAP that's why I assigned a high point to this.  Thanks!

Question by:res4me
    1 Comment
    LVL 1

    Accepted Solution

    Hi res4me,

    Call to undefined function: ldap_connect() means LDAP probably isn't enabled on your webserver.

    To check that it is enabled, run the script



    and check to see if you have a section regarding LDAP. If you don't, you'll need to enable "extension=php_ldap.dll" in your php.ini file, as well as copying some DLL files as detailed here:

    Hope this helps.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to dynamically set the form action using jQuery.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now