Java Reference
In-Depth Information
L ISTING 11.3
Continued
String[] phoneArray = {“(800) 123-4567”,
“(800) 123-4365”,
“(800) 135-4568”,
“(800) 320-7428”,
“(800) 622-4589”,
“(800) 124-4570”,
“(800) 827-4561”,
“(800) 425-1564”,
“(800) 626-7526”,
“(800) 322-8864”,
“(800) 821-3957”,
“(800) 120-5565”,
“(800) 320-0539”,
“(800) 123-456”};
try {
for (int i = 0; i < snArray.length; i++) {
String dn = “uid=” + uidArray[i] + “,ou=People,o=virtuas.com”;
HashMap atts = new HashMap();
atts.put(“cn”, fnArray[i] + “ “ + snArray[i]);
atts.put(“sn”, snArray[i]);
atts.put(“givenName”, fnArray[i]);
atts.put(“uid”, uidArray[i]);
atts.put(“mail”, uidArray[i] + “@virtuas.com”);
atts.put(“telephoneNumber”, phoneArray[i]);
lm.add(dn, atts, objectClass);
}
}
catch (NamingException e) {
e.printStackTrace();
}
}
}
We have already written the foundation for many simple LDAP applications. Here is an exam-
ple of a servlet that selects information from an LDAP server by searching on the user's last
name and then outputs the results. The full listing for LDAPTestServlet is in Listing 11.4.
Search WWH ::




Custom Search