August 2001
Intermediate to advanced
976 pages
38h 8m
English
The
CFLDAP tag can query an LDAP directory and return
the results as a ColdFusion query object. This gives you tremendous
flexibility in how you use the data. The query object can be output
to the browser using CFOUTPUT or used to feed
directory information to other functions or templates.
Once you know the available attributes of a given LDAP server, you can easily perform a basic query against the directory and output the results to the browser. Example 15-1 shows how to perform a simple query against the airius.com sample directory included with the Netscape Directory Server.
Example 15-1. Querying an LDAP Directory
<!--- query the LDAP server for all entries under the airius.com organization where the surname of the person begins with 's' and their location is 'Santa Clara'. Sort the results by surname and given name. ---> <CFLDAP ACTION="QUERY" NAME="MyLDAPQuery" SERVER="localhost" PORT="389" ATTRIBUTES="cn,sn,givenName,ou,l" MAXROWS="100" START="o=airius.com" SCOPE="Subtree" FILTER="(&(sn=s*)(l=Santa Clara))" SORT="SN, givenName" SORTCONTROL="nocase, ASC" TIMEOUT="90"> <!--- output the query results ---> <TABLE CELLPADDING="3" CELLSPACING="1"> <TR bgcolor="#CoCoCo"> <TH>Common Name (cn)</TH><TH>Surname (sn)</TH><TH>Given Name (givenName)</TH> <TH>Organizational Unit (ou)</TH><TH>Locality (l)</TH> </TR> <CFOUTPUT QUERY="MyLDAPQuery"> <TR bgcolor="##9999FF"> <TD><CFIF cn IS ""> <CFELSE>#cn#</CFIF></TD> <TD><CFIF sn IS ...
Read now
Unlock full access