PHP5.2 with LDAP Support

bobsthename

Verified User
Joined
Sep 23, 2009
Messages
59
Location
NZ
Operating System: Debian
PHP Version: 5.2.17

A client has asked for the PHP LDAP Module to be enabled but ive been having some troubles installing it.

I installed the package php5-ldap using
Code:
apt-get php5-ldap
and restarted apache

Then I followed the custombuild instructions on how to compile php with custom modules.
Adding --with-ldap \ to /directadmin/custombuild/custom/ap2/configure.php5 then running
Code:
./build php n
results in getting the following error;

checking for LDAP support... yes
checking for LDAP Cyrus SASL support... no
configure: error: Cannot find ldap.h

*** There was an error while trying to configure php. Check the custom/ap2/configure.php5 file

I did a search and couldnt find the ldap.h anywhere on the system.

So then I tried changing the configure.php5 file adding --with-ldap-dir=/usr/local/lib then php compilied fine.

I added extension=ldap.so in the phpini file and I copied the ldap.so from /usr/lib/php5/20090626+lfs to my php extension folder /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

restarted apache, but in phpinfo.php the ldap module is not loaded the only reference to ldap is in the configure command;

Code:
'./configure' '--with-apxs2' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gettext'
 '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-kerberos' '--with-ldap-dir=/usr/local/lib' 
'--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config'
 '--with-pcre-regex=/usr/local' '--with-pdo-mysql=/usr/local/mysql' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-zlib' 
'--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' 
'--enable-magic-quotes' '--enable-sockets' '--enable-mbstring'

Im at a loss as to what do do next. Do I need anyother packages to get PHP LDAP working on debian?

I also get this error in the apachelog;

Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so' 
- /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so: undefined symbol: gc_remove_zval_from_buffer in Unknown on line 0

Thanks
 
maybe the path to ldap.so is wrong, i use to move the so file in /usr/local/lib/ and point extension_dir into php.ini to that path.

Regards
 
After I installed the php5-ldap package I copied the new created file ldap.so from /usr/lib/php5/20090626+lfs to my php extension directory /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ so the file is definetly there

As a test I removed ldap.so from my php extension directory, then I got a file not found error;

Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so
' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0

When I put ldap.so back into my php extensions directory im back to the same error as before;

Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so
' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ldap.so: undefined symbol: gc_remove_zval_from_buffer in Unknown on line 0

My loaded php configuration file is /usr/local/lib/php.ini

Cheers
 
I found mod_ldap.so on my system too in /usr/lib/apache2/modules/mod_ldap.so

Is this the file Im supposed to be using to get this to work?

I copied mod_ldap.so into my php extension folder, changed my php.ini to extension=mod_ldap.so and restarted apache

I now get the following error;

Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/mod_lda
p.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/mod_ldap.so: undefined symbol: apr_pool_cleanup_null in Un
known on line 0

Any idea what this error means?
 
I suppose (and i should be totally wrong) that the ldap.so file you found in apache is for apache and not for php.

Im still sure you making some mistake on paths.

Again i suggest you this:

add

Code:
extension_dir = "/usr/local/lib"
Code:
extension=ldap.so

To your php.ini file and copy the ldap.so file into /usr/local/lib

Regards
 
Unfortunatly it produced the same error :(

Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/ldap.so' - /usr/local/lib/ldap.so: undefined symbol: gc_remove_zval_from_buffer in Unknown on line 0
 
It turns out that I had to install a package called libldap-dev for ldap.h
PHP is now compiled with ldap support directly instead of using the ldap extension and everything works fine :cool:

Many thanks
 
Back
Top