I’m looking to create a web based application in PHP that receives LDAP requests and sends LDAP responses back, but doesn’t actually use an LDAP server. Specifically I’d like to make the contacts table in a MySQL database available to Thunderbird as an LDAP address book.
Two Questions:
-
Is there an existing library for implementing an LDAP server with PHP? (The PHP_LDAP package is for creating an LDAP client, where the PHP application connects to an existing LDAP server.)
-
How does LDAP data actually get from the client into my script? Does LDAP travel over HTTP? Where the request would show up in:
$HTTP_RAW_POST_DATA
or similar? Can Apache handle LDAP requests and pass them into my script or is it a completely different protocol that requires a different “listener” application to handle?
The LDAP protocol is not natively handled by Apache, and I’ve not seen any Apache modules that handle that protocol. I don’t believe you’ll be able to do it using PHP through Apache. You might be able to implement a pure PHP server (see http://php.net/manual/en/function.stream-socket-server.php) and then implement the LDAP protocol packet parser in PHP as well. I don’t believe there is a native ASN1 parser for PHP, but you might be able to find one in C and somehow integrate it.