Java Reference
In-Depth Information
L ISTING 11.2
Continued
public int getSearchScope() {
return searchScope;
}
public void setSearchScope(int sc) {
searchScope = sc;
}
}
Accessing LDAP from a Servlet
By using the LDAP manager class that we have developed, accessing the LDAP server from
any servlet is very simple. You acquire all the information you need to perform the specific
operation and then make the appropriate call to LDAPManager .
If you download the source code for this topic, an extra class is provided to help load several
people into a LDAP server. This class is named LDAPInsertData . All you need to do is com-
pile it and run it to insert 14 people into the server. This will work as long as you have installed
the root of your LDAP tree as “o=virtuas.com” . The source code for LDAPInsertData appears
in Listing 11.3.
L ISTING 11.3
LDAPInsertData.java
import java.util.HashMap;
import javax.naming.NamingException;
public class LDAPInsertData {
public LDAPInsertData() {
}
public static void main(String[] args) {
LDAPManager lm = new LDAPManager();
String[] objectClass = {“top”,
“person”,
“organizationalPerson”,
“inetOrgPerson”};
Search WWH ::




Custom Search