Java Reference
In-Depth Information
HashMap modifications = new HashMap();
modifications.put(“mail”, “proy@roy.com”);
lm.modify(“uid=proy,ou=People,o=virtuas.com”, modifications,
DirContext.REPLACE_ATTRIBUTE);
}
catch (NamingException e) {
e.printStackTrace();
}
In this example we are replacing the existing value for the e-mail address with the new value of
“proy@roy.com” . This change is made to the object specified by the DN “uid=proy,
ou=People, o=virtuas.com” . It is important to note that more than one attribute can be modi-
fied at the same time, however the attributes will all be bound by the same modification opera-
tor.
The full listing for the manager class we have been developing appears in Listing 11.2.
L ISTING 11.2
LDAPManager.java
import java.util.Map;
import java.util.Vector;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import javax.naming.NamingEnumeration;
import javax.naming.directory.*;
import javax.naming.NamingException;
public class LDAPManager {
protected String factory = “com.sun.jndi.ldap.LdapCtxFactory”;
protected String serverName = “serverName”;
protected int port = 389;
protected String securityAuthentication = “simple”;
protected String dirManager = “cn=Directory Manager”;
protected String dirManagerPw = “directory”;
protected String searchBase = null;
protected int searchScope = SearchControls.SUBTREE_SCOPE;
public LDAPManager() {
}
Search WWH ::




Custom Search