Using PHP With LDAP (part 1) (
Page 1 of 6 )
Among its many other capabilities, PHP also comes with a
full-featured API to connect to, and communicate with, LDAP directory
servers. This article explores how PHP and LDAP can be used together,
beginning with a crash course in LDAP basics and proceeding to a series of
simple examples that demonstrate how PHP can be used to search an LDAP
directory and format the results for the Web.One of the reasons for PHP's immense popularity is its support for a wide
variety of different Internet technologies. It is this support, coupled with the
speed with which new language extensions get added to the source tree, that
keeps PHP ahead of other competing languages in the same category, and ensures
the continuity (and future growth) of the fan following it currently
enjoys.
One such Internet technology is LDAP, the Lightweight Directory
Access Protocol. In case you're not familiar with LDAP, it is a protocol
designed to allow quick, efficient searches of directory services. Built around
Internet technologies, LDAP makes it possible to easily update and query
directory services over standard TCP/IP connections, and includes a host of
powerful features, including security, access control, data replication and
support for Unicode.
PHP has shipped with support for LDAP since version
3.x of the language, and today comes with built-in support to connect to LDAP
databases, perform queries and process result sets. These capabilities make PHP
extremely popular among developers who need to create Web applications that
interface with LDAP directories - for example, online address books and
Web-based directories and directory search agents. Though these sound like
intimidating projects to take on, they're actually pretty simple - as you'll
see, PHP makes otherwise complex processes seem almost friendly via its powerful
functions and sophisticated capabilities.
Over the next few pages, I'm
going to introduce you to the LDAP functions that ship with PHP, demonstrating
how they can be used to rapidly create a Web-based interface to an LDAP
directory; this interface will allow users to perform queries and add and remove
entries from the directory using a standard Web browser. I'll assume here that
you have a working knowledge of PHP fundamentals, a development environment with
a working PHP build, and a sense of humour. LDAP knowledge would be a bonus,
although it is not a requirement - this tutorial does include a brief discussion
of LDAP basics.
Got 'em all? Flip the page, and let's get
going!