LDAP Classes
Implements Java LDAP

com.novell.ldap
Class LDAPModification

java.lang.Object
  extended bycom.novell.ldap.LDAPModification
All Implemented Interfaces:
java.io.Serializable

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

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.
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.
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(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.
static java.lang.Object readDSML(java.io.InputStream input)
          This method is used to deserialize the DSML encoded representation of this class.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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(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:
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.

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.

toString

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

Returns:
The string representation of this class.

LDAP Classes
Implements Java LDAP

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