Modifying LDAP Entries

The best way to illustrate adding, updating, and deleting LDAP entries is to build an example administrative interface that can perform these tasks. The main template of the application is a template named index.cfm, which is shown in Example 15-3. This template contains an HTML form with a single select box control containing the common names (first and last names) of each entry in the LDAP server. Below the select box are three buttons—one for adding a new entry, one for modifying an existing entry, and one for deleting an entry.

Example 15-3. Main LDAP administration template

<!--- Query the ldap server for all entries ---> <cfldap action="Query" name="GetEntries" server="localhost" attributes="dn,cn,sn,givenName" filter="(sn>=A)" start="dc=example,dc=com" scope="subtree" sort="sn, givenname"> <html> <head> <title>LDAP Administration</title> </head> <center> <h2>LDAP Administration</h2> <!--- If a message was passed from the action form, display it ---> <cfif IsDefined('URL.Message')> <cfoutput> <h3 style="color: red;">#Message#</h3> </cfoutput> </cfif> <!--- Display the common name for each entry in a multi-select box. Assign the DN to each option value ---> <form name="MyForm" action="Action.cfm" method="post"> <select name="dn" size="5"> <cfoutput query="GetEntries"> <option name="DN" value="#DN#">#CN#</option> </cfoutput> </select> <br> <input name="submit" type="Submit" value="Add"> <input name="submit" type="Submit" value="Update"> <input name="submit" ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.