Java Reference
In-Depth Information
public Attributes parseAttributes(HashMap attributes) {
11
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)attIter.next();
Object value = attributes.get(attName);
// create a new Attribute
Attribute attribute = new BasicAttribute(attName, value);
// add the attribute to the list of attributes
newAtts.put(attribute);
}
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”,
“person”,
“organizationalPerson”,
“inetOrgPerson”};
String dn = “uid=bjones,ou=People,o=virtuas.com”;
HashMap atts = new HashMap();
atts.put(“cn”, “Bob Jones”);
atts.put(“sn”, “Jones”);
atts.put(“givenName”, “Bob”);
atts.put(“uid”, “bjones”);
atts.put(“mail”, “bjones@virtuas.com”);
atts.put(“telephoneNumber”, “(800) 456-4908”);
 
Search WWH ::




Custom Search