LDAP Authentication on Windows

2019-02-24 09:14发布

问题:

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["myUserName@mydomain.com"];
$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>";
}
?>

回答1:

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



回答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)