To delete a directory entry, you must specify the entry DN.
The following example builds on the code that adds an entry. It adds Retrieve and Delete buttons. The Retrieve button lets you view a user's information in the form before you delete it.
The following table describes the code:
Code |
Description |
---|---|
<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]> |
If the user clicks Retrieve, queries the directory and gets the information for the specified User ID. Sets the form field's Value attribute to the corresponding query column. 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. |
<cfelseif Form.action is "Delete"> <cfldap action="delete" dn="uid=#Trim(Form.UID)#, ou=People, o=Airius.com" server=#myServer# username=#myUserName# password="password"> <cfoutput><h3>Entry for User ID #Form.UID# has been deleted</h3></cfoutput> |
The user clicks delete, deletes the entry with the specified User ID and informs the user that the entry was deleted. |
  <input type="Submit" name="action" value="Retrieve" tabindex="7">   <input type="Submit" name="action" value="Delete" tabindex="8"></td> |
Displays submit buttons for the Retrieve and Delete actions. |