User Guide

Table Of Contents
Updating an LDAP directory 531
Reviewing the code
The following table describes the code:
Code Description
<cfset myServer="ldap.myco.com">
<cfset myUserName="cn=Directory
Manager">
<cfset myPassword="password">
Initializes the LDAP connection information
variables. Uses variables for all connection
information so that any changes have to be made in
only one place.
<cfparam name="fullNameValue"
default="">
<cfparam name="surnameValue"
default="">
<cfparam name="emailValue"
default="">
<cfparam name="phoneValue"
default="">
<cfparam name="uidValue" default="">
Sets the default values of empty strings for the form
field value variables. The data entry form uses
cfinput fields with value attributes so that the form
can be prefilled and so that, if the user submits an
incomplete form, ColdFusion can retain any
entered values in the form when it redisplays the
page.
<cfif isdefined("Form.action") AND
Trim(Form.uid) IS NOT "">
Ensures that the user entered a User ID in the form.
<cfif Form.action is "add">
If the user clicks Add, processes the code that
follows.
<cfif Trim(Form.fullName) is ""
OR Trim(Form.surname) is ""
OR Trim(Form.email) is ""
OR Trim(Form.phone) is "">
<h2>You must enter a value in every
field.</h2>
<cfset fullNameValue=
Form.fullName>
<cfset surnameValue=
Form.surname>
<cfset emailValue=Form.email>
<cfset phoneValue=Form.phone>
<cfset uidValue=Form.uid>
If any field in the submitted form is blank, display a
message and set the other form fields to display
data that the user submitted.
<cfelse>
<cfset attributelist=
"objectclass=top,person,
organizationalperson,
inetOrgPerson;
cn=#Trim(Form.fullName)#;
sn=#Trim(Form.surname)#;
mail=#Trim(Form.email)#;
telephonenumber=
#Trim(Form.phone)#;
ou=Human Resources;
uid=#Trim(Form.uid)#">
If the user entered data in all fields, sets the
attributelist variable to specify the entry’s attributes,
including the object class and the organizational
unit (in this case, Human Resources).
The
Trim function removes leading or trailing
spaces from the user data.