WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] PHP LDAP Extension  (Read 7346 times)

Offline KHarvey

  • Full Member
  • ***
  • Posts: 102
[SOLVED] PHP LDAP Extension
« on: February 26, 2013, 11:37:53 AM »
I am attempting to get LDAP authentication up and running using PHP but for some reason I am unable to get the LDAP PHP module to load.
I'm running TC 4.6.1
I have installed
apache2-mod-php5.tcz
apache2.tcz
php5.tcz
mysql.tcz

When I do phpinfo() it shows that PHP was configured with LDAP
Configure Command    './configure' '--prefix=/usr/local' '--localstatedir=/var' '--sysconfdir=/usr/local/etc' '--mandir=/usr/local/share/man' '--enable-shared' '--enable-static' '--enable-libgcc' '--enable-bcmath=shared' '--enable-soap=shared' '--enable-dmalloc=shared' '--with-apxs2=/usr/local/bin/apxs2' '--with-recode=shared,/usr/local' '--with-snmp=shared,/usr/local' '--enable-sockets=shared' '--enable-dba=shared' '--enable-zip=shared' '--with-xsl=shared,/usr/local' '--with-config-file-path=/usr/local/apache2/conf/php5/' '--with-config-file-scan-dir=/usr/local/apache2/conf/php5/extensions/' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-jpeg-dir=/usr' '--with-xpm-dir=/usr' '--with-libexpat-dir=shared,/usr/local' '--with-gmp=shared,/usr/local' '--with-gettext=shared,/usr/local' '--with-iconv=shared,/usr/local' '--with-pgsql=shared,/usr/local' '--with-pdo-pgsql=shared,/usr/local' '--enable-gd-native-ttf' '--enable-exif=shared' '--enable-ftp=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--enable-sysvmsg=shared' '--enable-wddx=shared' '--enable-shmop=shared' '--with-readline=shared,/usr/local' '--with-sqlite3=shared,/usr/local' '--with-pdo-sqlite=shared,/usr/local' '--with-mhash=shared,/usr/local' '--with-gd=shared' '--with-gdbm=shared,/usr/local' '--enable-calendar=shared' '--with-libxml-dir=shared,/usr/local' '--with-openssl=shared,/usr/local' '--with-pcre-regex=/usr/local' '--with-zlib=shared,/usr' '--with-zlib-dir=/usr' '--with-bz2=shared,/usr/local' '--with-curl=shared,/usr/local' '--with-mcrypt=shared,/usr/local' '--with-ldap=shared,/usr/local' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-pdo-mysql=shared,mysqlnd' '--enable-intl=shared' '--disable-phar' '--disable-cli' '--without-pear' '--with-enchant=shared,/usr/local' '--disable-cgi' '--with-unixODBC=shared,/usr/local' '--with-pdo-odbc=shared,unixODBC' '--with-db4=shared,/usr/local' '--enable-mbstring=shared'

But I don't see anything else in the phpinfo() about LDAP.  I tried adding:
Code: [Select]
extensions=ldap.so
to my php.ini file and rebooted the server, but still nothing.
I did a search for ldap.so and it was found in:
Code: [Select]
/tmp/tcloop/apache2-mod-php5/usr/local/lib/php/extensions/no-debug-zts-20100525/ldap.so
/usr/local/lib/php/extensions/no-debug-zts-20100525/ldap.so

When I try to run ldap_connect I receive the following error:
Code: [Select]
Fatal error: Call to undefined function ldap_connect() in /usr/local/apache2/htdocs/test.php on line 17

I have a sneaking suspicion that I am missing something obvious, but I just can't see it.

Has anyone else ran into this issue, or possibly know what I am doing wrong?
« Last Edit: February 26, 2013, 12:36:37 PM by KHarvey »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11046
Re: PHP LDAP Extension
« Reply #1 on: February 26, 2013, 12:21:38 PM »
Likely an optional dependency. Try "ldd /usr/local/lib/php/extensions/no-debug-zts-20100525/ldap.so"
The only barriers that can stop you are the ones you create yourself.

Offline KHarvey

  • Full Member
  • ***
  • Posts: 102
Re: PHP LDAP Extension
« Reply #2 on: February 26, 2013, 12:26:10 PM »
Now that I have flushed some of my Apache logs I now see there is another error that is being generated:
Code: [Select]
PHP Warning:  PHP Startup:  Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20100525/ldap.so' - libldap-2.4.so.2:  cannot open shared object file:  No such file or directory in Unknown on line 0

I tried searching for libldap-2.4.so.2 but I did not find it anywhere. Am I missing a dependency?

**EDIT**
While typing this post curaga responded.

Yup I am missing 2 dependencies when I run the ldd command:
libldap-2.4.so.2
liblber-2.4.so.2
Both were not found.

Offline KHarvey

  • Full Member
  • ***
  • Posts: 102
Re: PHP LDAP Extension
« Reply #3 on: February 26, 2013, 12:33:04 PM »
So I found the libldap-2.4.so.2 and liblber-2.4.so.2 in the openldap extension.

But now I am missing:
libgcrypt.so.11
libgpg-error.so.0

Not sure what extensions these ones are in, but I am searching now.

Offline KHarvey

  • Full Member
  • ***
  • Posts: 102
Re: PHP LDAP Extension
« Reply #4 on: February 26, 2013, 12:36:13 PM »
Okay, so I am blind libgcrypt.tcz exists.

So I had to load openldap.tcz and libgcrypt.tcz and now it is magically working.

Thanks for the help curaga, I completely forgot about ldd.  I new it was something simple.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11046
Re: [SOLVED] PHP LDAP Extension
« Reply #5 on: February 26, 2013, 01:34:13 PM »
The PHP info file is not very clear on what features are optional.
The only barriers that can stop you are the ones you create yourself.