User Guide

Table Of Contents
524 Chapter 23: Managing LDAP Directories
This tag returns entries for all the people in the organization and entries for all the groups. The
group entries have a different object class, and therefore different attributes from the person
entries. If ColdFusion returned both types of entries in one query object, some rows would have
only the group-specific attribute values and the other rows would have only person-specific
attribute values. Instead, ColdFusion returns a structure in which each attribute is an entry.
Example: querying an LDAP directory
The following example uses the
cfldap tag to get information about the people in the Airius
corporations Santa Clara office. Users can enter all or part of a persons name and get a list of
matching names with their departments, e-mail addresses, and telephone numbers.
This example uses the sample Airius corporate directory that is distributed with the Netscape
Directory Server. If you do not have access to this directory, modify the code to work with your
LDAP directory.
To query an LDAP directory:
1.
Create a file that looks like the following:
<!--- This example shows the use of CFLDAP --->
<html>
<head> <title>cfldap Query Example</title> </head>
<h3>cfldap Query Example</h3>
<body>
<p>This tool queries the Airius.com database to locate all people in
the company's Santa Clara office whose common names contain the
text entered in the form.</p>
<p>Enter a full name, first name, last name, or name fragment.</p>
<form action="cfldap.cfm" method="POST">
<input type="text" name="name"><br><br>
<input type="submit" value="Search">
</form>
<!--- make the LDAP query --->
<!-- Note that some search text is required.
A search filter of cn=** would cause an error -->
<cfif (isdefined("form.name") AND (form.name IS NOT ""))>
<cfldap
server="ldap.airius.com"
action="query"
name="results"
start="ou=People, o=Airius.com"
scope="onelevel"
filter="(&(cn=*#form.Name#*)(l=Santa Clara))"
attributes="cn,sn,ou,mail,telephonenumber"
sort="ou,sn"
maxrows=100
timeout=20000
>