Java Reference
In-Depth Information
L ISTING 21.7
21
Continued
// Get the givenName off of the request
String givenName = request.getParameter(“givenName”);
// Get the mail off of the request
String mail = request.getParameter(“mail”);
// Get the tn off of the request
String tn = request.getParameter(“tn”);
// Create the UID
String dn = “uid=” + uid + “,ou=People,o=virtuas.com”;
// Build the HashMap of Attribute to add
HashMap atts = new HashMap();
atts.put(“cn”, givenName + “ “ + sn);
atts.put(“sn”, sn);
atts.put(“givenName”, givenName);
atts.put(“uid”, uid);
atts.put(“mail”, mail);
atts.put(“telephoneNumber”, tn);
// create and initialize an LDAPManager
LDAPManager lm = new LDAPManager();
// Add the Person to the directory
lm.add(dn, atts, objectClass);
}
}
The LDAPDelete Service
The LDAPDelete class is also an implementation of the Service interface. Its execute()
method starts its execution when a user selects the Delete link after a LDAPDirectory service
has forwarded search results to the directory.jsp page. It then gets the dn from the request
and passes it to the LDAPManager.remove() method, which removes the named People object
from the LDAP server. Listing 21.8 gives the source for the LDAPDelete service.
L ISTING 21.8
LDAPDelete.java
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
Search WWH ::




Custom Search