Adobe COLDFUSION 9 Manual page 468

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
2
At the top of the file, change the
valid for your LDAP server.
Save the page as update_ldap.cfm and run it in your browser.
3
Reviewing the code
The following table describes the code:
Code
<cfset myServer="ldap.myco.com">
<cfset myUserName="cn=Directory Manager">
<cfset myPassword="password">
<cfparam name="fullNameValue" default="">
<cfparam name="surnameValue" default="">
<cfparam name="emailValue" default="">
<cfparam name="phoneValue" default="">
<cfparam name="uidValue" default="">
<cfif isdefined("Form.action") AND
Trim(Form.uid) IS NOT "">
<cfif Form.action is "add">
<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>
<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)#">
<cfldap action="add"
attributes="#attributeList#"
dn="uid=#Trim(Form.uid)#, ou=People,
o=Airius.com" server=#myServer#
username=#myUserName# password=#myPassword#>
<cfoutput>
<h3>Entry for User ID #Form.uid# has been
added</h3>
</cfoutput>
</cfif>
</cfif>
</cfif>
,
, and
myServer
myUserName
Description
Initializes the LDAP connection information variables. Uses variables for all
connection information so that any changes have to be made in only one
place.
Sets the default values of empty strings for the form field value variables.
The data entry form uses cfinput fields with
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.
Ensures that the user entered a User ID in the form.
If the user clicks Add, processes the code that follows.
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.
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.
Adds the new entry to the directory.
Last updated 8/5/2010
variable assignments to values that are
myPassword
value
463
attributes so that the

Advertisement

Table of Contents
loading

Table of Contents