[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2004-11-08
Medium Priority
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 = 'yikes@mypage.com';
      $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

Accepted Solution

AVSEC earned 2000 total points
ID: 12529199
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: http://nz2.php.net/manual/en/ref.ldap.php#ldap.requirements

Hope this helps.


Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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