开发者

PHP5-ldap and LDAPS under Apache2 (not working) vs CLI (working)

开发者 https://www.devze.com 2023-04-09 03:27 出处:网络
I\'m trying to connect to an LDAPS server using A开发者_开发问答pache2, PHP5.3, with the php5-ldap package.

I'm trying to connect to an LDAPS server using A开发者_开发问答pache2, PHP5.3, with the php5-ldap package.

When I set the code off using PHP-CLI, it works fine.

When I execute the same code under Apache2, the bind always fails.

I've set TLS_REQCERT to NEVER, hence the CLI version working.

What am I doing wrong?

Code:

<?php

   // using anonymous ldap bind
   // connect to ldap server
   $ldapconn = ldap_connect("ldaps://XXX.XXX.com")
       or die("Could not connect to LDAP server.");

   if ($ldapconn)
   {
       // binding anonymously
       $ldapbind = ldap_bind($ldapconn) or die("Couldn't bind\n");

       if ($ldapbind) {
           echo "LDAP anonymous bind successful...";
       } else {
           echo "LDAP anonymous bind failed...";
       }
   }

   $res = ldap_search($ldapconn, 'ou=XXX,o=XXX', '(sn=XXX*)');
   $info = ldap_get_entries($ldapconn, $res);

   echo "<pre>" . var_dump($info) . "</pre>";

   ldap_unbind($ldapconn);

?>


Review php.ini, and make sure the ext is being loaded with phpinfo(). Differint sapi's might try loading php.ini from differint locations, so also check the location of php.ini within phpinfo() and make sure it's loading the one your expecting.

0

精彩评论

暂无评论...
验证码 换一张
取 消