Java Reference
In-Depth Information
public Attributes parseAttributes(HashMap attributes) {
if (attributes == null) {
return null;
Attributes newAtts = new BasicAttributes();
// get an iterator for all of the keys in the HashMap
Iterator attIter = attributes.keySet().iterator();
while (attIter.hasNext()) {
// get the value for the key.
String attName = (String);
Object value = attributes.get(attName);
// create a new Attribute
Attribute attribute = new BasicAttribute(attName, value);
// add the attribute to the list of attributes
return newAtts;
Client code can use this method to add objects to any place in the directory tree. Because you
are dealing with a phone book, you will be adding the proper information in the People
branch. The client code to do this would look like this:
LDAPManager lm = new LDAPManager();
String[] objectClass = {“top”,
String dn = “uid=bjones,ou=People,”;
HashMap atts = new HashMap();
atts.put(“cn”, “Bob Jones”);
atts.put(“sn”, “Jones”);
atts.put(“givenName”, “Bob”);
atts.put(“uid”, “bjones”);
atts.put(“mail”, “”);
atts.put(“telephoneNumber”, “(800) 456-4908”);
Search WWH ::

Custom Search