The widespread use of the Lightweight Directory Access Protocol (LDAP) to build searchable directory structures, internally and across the web, gives you opportunities to add value to the sites that you create. You can index contact information or other data from an LDAP-accessible server and let users search it.
When creating an index from an LDAP query, remember the following considerations:
In the following example, the search criterion is records with a telephone number in the 617 area code. Generally, LDAP servers use the Distinguished Name (dn
) attribute as the unique identifier for each record so that attribute is used as the key
value for the index.
<!--- Run the LDAP query. ---> <cfldap name="OrgList" server="myserver" action="query" attributes="o, telephonenumber, dn, mail" scope="onelevel" filter="(|(O=a*) (O=b*))" sort="o" start="c=US"> <!--- Output query record set. ---> <cfoutput query="OrgList"> DN: #dn# <br> O: #o# <br> TELEPHONENUMBER: #telephonenumber# <br> MAIL: #mail# <br> =============================<br> </cfoutput> <!--- Index the record set. ---> <cfindex action="update" collection="ldap_query" key="dn" type="custom" title="o" query="OrgList" body="telephonenumber"> <!--- Search the collection. ---> <!--- Use the wildcard * to contain the search string. ---> <cfsearch collection="ldap_query" name="s_ldap" criteria="*617*" maxrows = "100"> <!--- Output returned records. ---> <cfoutput query="s_ldap"> #Key#, #Title#, #Body# <br> </cfoutput>