Adobe COLDFUSION 9 Manual page 471

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Code
<cfelseif Form.action is "Retrieve">
<cfldap name="GetEntry"
server=#myServer#
action="query"
attributes="cn,sn,mail,telephonenumber,uid"
scope="subtree"
filter="uid=#Trim(Form.UID)#"
start="o=Airius.com">
<cfset fullNameValue = GetEntry.cn[1]>
<cfset surnameValue = GetEntry.sn[1]>
<cfset emailValue = GetEntry.mail[1]>
<cfset phoneValue =
GetEntry.telephonenumber[1]>
<cfset uidValue = GetEntry.uid[1]>
<cfelseif Form.action is "Delete">
<cfldap action="delete"
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 deleted
</h3>
&nbsp
<input type="Submit"
name="action"
value="Retrieve"
tabindex="7">
&nbsp
<input type="Submit"
name="action"
value="Delete"
tabindex="8"></td>
Updating a directory entry
The cfldap tag lets you change the values of entry attributes. To do so, you specify the entry DN in the
list the attributes to change and their new values in the
The following example builds on the code that adds and deletes an entry. It can update one or more of an entry's
attributes. Because the UID is part of the DN, you cannot change it.
1
Open update_ldap.cfm, which you created in
Between the
block and the
2
cfelseif
<cfelseif Form.action is "Update">
<cfset attributelist="cn=#Trim(form.FullName)#; sn=#Trim(Form.surname)#;
mail=#Trim(Form.email)#;
telephonenumber=#Trim(Form.phone)#">
<cfldap action="modify"
modifytype="replace"
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 updated</h3>
</cfoutput>
At the end of the code for the Delete button (the
3
the
mark.
</td>
Description
If the user clicks Retrieve, queries the directory and gets the information for the
specified User ID.
Sets the form field's
Value
This example uses the array index [1] to identify the first row of the GetEntry
query object. Because the query always returns only one row, the index can be
omitted.
The user clicks delete, deletes the entry with the specified User ID, and informs
the user that the entry was deleted.
Displays submit buttons for the Retrieve and Delete actions.
attribute.
attributes
"Adding a directory
tag, add the following code:
</cfif
tag with
input
Value=Delete
Last updated 8/5/2010
attribute to the corresponding query column.
entry" on page 460.
at the bottom of the form
466
attribute, and
dn
, delete
)

Advertisement

Table of Contents
loading

Table of Contents