Java Reference
In-Depth Information
try {
lm.add(dn, atts, objectClass);
}
catch (NamingException e) {
e.printStackTrace();
}
After all of the information has been collected, all you need to do is ask your LDAPManager to
add the object to the server. Here you define the person object by combining the inherited
objects that include the attributes that you want. These include top , person ,
organizationalPerson , and inetOrgPerson . To find this information, you have to know a lit-
tle about the schema that came with the LDAP server you are using. These object definitions
make up the standard user object in the Netscape Directory Server.
Removing an Object
Removing an object from an LDAP server is very easy. There is little information that is neces-
sary. All that is required is the object's DN. Hand the DN to the Context and ask it to remove
the object for you. It is that simple.
The method to perform the deletion from an LDAP server appears in the manager class as fol-
lows:
public void remove(String dn) throws NamingException {
// perform the deletion from the LDAP server based on the objects DN
DirContext ctx = getInitialContext(getEnvironment());
ctx.destroySubcontext(dn);
}
All the client code must do is provide the manager with the object's DN. The method would be
invoked like this:
LDAPManager lm = new LDAPManager();
try {
lm.remove(“uid=bjones,ou=People,o=virtuas.com”);
}
catch (NamingException e) {
e.printStackTrace();
}
That is all there is to removing entire objects from a directory service.
Search WWH ::




Custom Search