Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP how to specify ldap.conf location?

Tags:

php

ldap

I have a PHP compiled with ldap support and it is working as expected. Now, I need to do some configuration for SSL/TLS but I have no ldap.conf file.

php -i says it was compiled --with-ldap=/usr so I suppose I should make the ldap.conf file in /usr, but I have no write permission there because of an architectural limitation of the device.

How can I specify the path to ldap.conf for php? Is there an php.ini setting? Maybe a parameter in command line?

like image 386
Patkos Csaba Avatar asked May 18 '11 14:05

Patkos Csaba


People also ask

Where is LDAP Conf located?

By default, ldap. conf resides in the /etc directory, but you can override the path and file name of ldap. conf with the LDAPCONF environment variable.

How can I tell if PHP supports LDAP?

You can try and check it with extension_loaded() like this: $builtWithLdap = extension_loaded('ldap'); or alternativly as a crowbar approach, just check if one of the functions exists: $builtWithLdap = function_exists('ldap_add');

How enable LDAP in PHP Linux?

Search for ExtensionList in the php. ini file. Uncomment the extension=php_ldap. dll line, if not present then add this line in the file and save the file.

What is Tls_reqcert?

TLS_REQCERT <level> Specifies what checks to perform on server certificates in a TLS session, if any. The <level> can be specified as one of the following keywords: never The client will not request or check any server certificate. allow The server certificate is requested.


2 Answers

See http://php.net/manual/en/function.ldap-connect.php#36156:

You also need to place those same settings in a file within the Apache Web user homedir called .ldaprc e.g.: cp /usr/local/openldap/etc/openldap/ldap.conf ~www/.ldaprc )

The apache web server root directory is the key here, as well as .ldaprc.

Also see the official ldap man pages:

Users may create an optional configuration file, ldaprc or .ldaprc, in their home directory which will be used to override the system-wide defaults file. The file ldaprc in the current working directory is also used.

like image 176
cweiske Avatar answered Sep 30 '22 03:09

cweiske


Under XAMPP on Windows the ldap.conf must be either in the root of the system (c:\ldap.conf, PHP 5.3.3 if I remember correctly) or in C:\openldap\sysconf\ depending on the PHP version. It seems the path is not configurable because hardcoded in the Windows PHP DLLs. See the comments at http://se2.php.net/manual/en/ref.ldap.php

like image 21
jayo Avatar answered Sep 30 '22 03:09

jayo