• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

15. Interfacing with LDAP-Enabled Direct... > 15.2. Querying an LDAP Directory

Querying an LDAP Directory

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.

Performing an LDAP Query

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 example.com sample directory included with the Netscape Directory Server.

Example 15-1. Querying an LDAP directory
<!--- query the LDAP server for all entries 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,mail,l" 
        maxrows="100"
        start="dc=example,dc=com" 
        scope="Subtree" 
        filter="(&(sn=s*)(l=Santa Clara))"   
        sort="sn, givenNnme" 
        sortcontrol="nocase, ASC"              
        timeout="90">
        
<html>
<head>
  <title>Example 15-1: Querying an LDAP Directory</title>
  <style type="text/css">
    th {
      background-color : #C0C0C0;
      font-weight : bold;
     ....

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint