LDAP Authentication on Windows

10,300

Solution 1

The PHP LDAP extension is required to use LDAP functions. Just check it's uncommented in your php.ini (extension=php_ldap.dll)

Solution 2

The PHP extension is clearly not loading. A couple things to try:

  • run 'php -m' from the command line and ensure that ldap is in the list of modules, and that there are no errors related to ldap.
  • ensure that the apache php module is using the php.ini that you modified ( and look for php.ini on the page)
Share:
10,300

Related videos on Youtube

ilhnctn
Author by

ilhnctn

Computer Engeneer & Social Activist  Programming & Computer Skills      - Full Stack Web Developer      - Python - PHP - Javascript (Django/Django Rest Framework, Zend Framework 2, Tornado, Node Js)      - Docker, Kubernetes, AWS Tools (Lambda, S3, EC2) Wishes a world without countries, nations and religions. At least wants to imagine... Favourite Writers Fyodor Dostoyevski Maksim Gorki Umberto Eco Hermann Hesse Gabriel Garcia Marquez Milan Kundera You can find me with @ilhnctn at Github and all social networks

Updated on September 19, 2022

Comments

  • ilhnctn
    ilhnctn over 1 year

    i have an 64 bit Windows Platform and Postgresql 8.4 installed(as Apache, EnterpriseDB-ApachePHP is installed on Pstgres).. I need to authenticate to system using Active Directory(or LDAP?) credentials but even tough i enabled LDAP and restarted Apache on error log i see PHP Fatal error: Call to undefined function ldap_connect() in path/to/my/phpfile.. PHP script i use is below,

    <?php
    
    $user = $_POST["[email protected]"];
    $pass = $_POST["muPassword"];
    //in our system, we already use this account for LDAP authentication on the server above
    $ldap_serv = 'ldap://192.168.69.10';
    $ldap_port = '389';
    $lc = ldap_connect($ldap_serv, $ldap_port);
    ldap_set_option($lc, LDAP_OPT_REFERRALS, 0);
    ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, 3);
    $ldapbind = ldap_bind($lc,$user,$pass);
    if ($ldapbind == false) {
      echo 'username or password is wrong';
    }
    else
    {
    echo "You Logged in";
    echo "<br><br><br>Wellcome<br><br><br>";
    }
    ?>
    
  • ilhnctn
    ilhnctn over 11 years
    @dealby good answer but i couldn't rum 'php -m' from command line. I'm using Postgresql(which lies on a version of Apache). And i'm uncommenting extention from php.ini of Apache inside Postgres
  • dearlbry
    dearlbry over 11 years
    @ilis This is confusing to me.... Postgres is your database - I'm not sure what you mean by Apache inside of it. Theoretically, apache is using a php module to interpret your scripts and serve up the results. Then there's usually php.exe as well, which allows you to run php scripts from the command line. Do you see ldap support when you run a script that has <? phpinfo(); ?> in it? Anything in the apache logs about the php ldap module not being loaded?
  • ilhnctn
    ilhnctn over 11 years
    sorry, i mean Apache is a part of Postgresql, i havent installed any other Apache or PHP modules, i tried phpinfo() but there is almost nothing about ldap, which means it isnt activated.
  • dearlbry
    dearlbry over 11 years
    In the phpinfo() output, do you see the same php.ini file that you modified? Can you check your apache logs to ensure there were no errors when it was restarted?
  • ilhnctn
    ilhnctn over 11 years
    I uninstalled postgres and installed WAMP, uncommented that line and it works properly
  • Makarand Mane
    Makarand Mane almost 10 years
    when I saw php.ini file this (extension = php_ldap.dll) was not there I just added this line and ldap enabled.