All LDAP Classes
Internal LDAP Classes

com.novell.ldap
Class LDAPModification

java.lang.Object
  extended by com.novell.ldap.LDAPModification
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class LDAPModification
extends java.lang.Object
implements java.io.Externalizable

A single add, delete, or replace operation to an LDAPAttribute.

An LDAPModification contains information on the type of modification being performed, the name of the attribute to be replaced, and the new value. Multiple modifications are expressed as an array of modifications, i.e., LDAPModification[].

An LDAPModification or an LDAPModification array enable you to modify an attribute of an LDAP entry. The entire array of modifications must be performed by the server as a single atomic operation in the order they are listed. No changes are made to the directory unless all the operations succeed. If all succeed, a success result is returned to the application. It should be noted that if the connection fails during a modification, it is indeterminate whether the modification occurred or not.

There are three types of modification operations: Add, Delete, and Replace.

Add: Creates the attribute if it doesn't exist, and adds the specified values. This operation must contain at least one value, and all values of the attribute must be unique.

Delete: Deletes specified values from the attribute. If no values are specified, or if all existing values of the attribute are specified, the attribute is removed. Mandatory attributes cannot be removed.

Replace: Creates the attribute if necessary, and replaces all existing values of the attribute with the specified values. If you wish to keep any existing values of a multi-valued attribute, you must include these values in the replace operation. A replace operation with no value will remove the entire attribute if it exists, and is ignored if the attribute does not exist.

Additional information on LDAP modifications is available in section 4.6 of rfc2251.txt

Sample Code:

Adding, replacing, or deleting individual attribute values
ModifyAttrs.java

Deleting an attribute
DeleteAttribute.java

See Also:
LDAPConnection.modify(java.lang.String, com.novell.ldap.LDAPModification), LDAPAttribute, Serialized Form

Field Summary
static int ADD
          Adds the listed values to the given attribute, creating the attribute if it does not already exist.
private  LDAPAttribute attr
           
static int DELETE
          Deletes the listed values from the given attribute, removing the entire attribute (1) if no values are listed or (2) if all current values of the attribute are listed for deletion.
private  int op
           
static int REPLACE
          Replaces all existing values of the given attribute with the new values listed, creating the attribute if it does not already exist.
 
Constructor Summary
LDAPModification()
          This constructor was added to support default Serialization
LDAPModification(int op, LDAPAttribute attr)
          Specifies a modification to be made to an attribute.
 
Method Summary
 LDAPAttribute getAttribute()
          Returns the attribute to modify, with any existing values.
 int getOp()
          Returns the type of modification specified by this object.
(package private) static LDAPXMLHandler getXMLHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
          This method return the LDAPHandler which handles the XML (DSML) tags for this class
(package private)  void newLine(int indentTabs, java.io.Writer out)
           
static java.lang.Object readDSML(java.io.InputStream input)
          This method is used to deserialize the DSML encoded representation of this class.
 void readExternal(java.io.ObjectInput in)
          Reads the serialized object from the underlying input stream.
 java.lang.String toString()
          Returns a string representation of this class.
 void writeDSML(java.io.OutputStream oout)
          This method does DSML serialization of the instance.
 void writeExternal(java.io.ObjectOutput out)
          Writes the object state to a stream in XML format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

op

private int op

attr

private LDAPAttribute attr

ADD

public static final int ADD
Adds the listed values to the given attribute, creating the attribute if it does not already exist.

ADD = 0

See Also:
Constant Field Values

DELETE

public static final int DELETE
Deletes the listed values from the given attribute, removing the entire attribute (1) if no values are listed or (2) if all current values of the attribute are listed for deletion.

DELETE = 1

See Also:
Constant Field Values

REPLACE

public static final int REPLACE
Replaces all existing values of the given attribute with the new values listed, creating the attribute if it does not already exist.

A replace with no value deletes the entire attribute if it exists, and is ignored if the attribute does not exist.

REPLACE = 2

See Also:
Constant Field Values
Constructor Detail

LDAPModification

public LDAPModification()
This constructor was added to support default Serialization


LDAPModification

public LDAPModification(int op,
                        LDAPAttribute attr)
Specifies a modification to be made to an attribute.

Parameters:
op - The type of modification to make, which can be one of the following:
  • LDAPModification.ADD - The value should be added to the attribute
  • LDAPModification.DELETE - The value should be removed from the attribute
  • LDAPModification.REPLACE - The value should replace all existing values of the attribute

attr - The attribute to modify.
Method Detail

getAttribute

public LDAPAttribute getAttribute()
Returns the attribute to modify, with any existing values.

Returns:
The attribute to modify.

getOp

public int getOp()
Returns the type of modification specified by this object.

The type is one of the following:

Returns:
The type of modification specified by this object.

newLine

void newLine(int indentTabs,
             java.io.Writer out)
       throws java.io.IOException
Throws:
java.io.IOException

writeDSML

public void writeDSML(java.io.OutputStream oout)
               throws java.io.IOException
This method does DSML serialization of the instance.

Parameters:
oout - Outputstream where the serialzed data has to be written
Throws:
java.io.IOException - if write fails on OutputStream

readDSML

public static java.lang.Object readDSML(java.io.InputStream input)
                                 throws java.io.IOException
This method is used to deserialize the DSML encoded representation of this class.

Parameters:
input - InputStream for the DSML formatted data.
Returns:
Deserialized form of this class.
Throws:
java.io.IOException - when serialization fails.

getXMLHandler

static LDAPXMLHandler getXMLHandler(java.lang.String tagname,
                                    LDAPXMLHandler parenthandler)
This method return the LDAPHandler which handles the XML (DSML) tags for this class

Parameters:
tagname - Name of the Root tag used to represent this class.
parenthandler - Parent LDAPXMLHandler for this tag.
Returns:
LDAPXMLHandler to handle this element.

toString

public java.lang.String toString()
Returns a string representation of this class.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of this class.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the object state to a stream in XML format

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The ObjectOutput stream where the Object in XML format is being written to
Throws:
java.io.IOException - - If I/O errors occur

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the serialized object from the underlying input stream.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The ObjectInput stream where the Serialized Object is being read from
Throws:
java.io.IOException - - If I/O errors occur
java.lang.ClassNotFoundException - - If the class for an object being restored cannot be found.

All LDAP Classes
Internal LDAP Classes

Copyright ? 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000