1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 *******************************************************************************/
24 // Novell.Directory.Ldap.LdapModification.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
34 namespace Novell.Directory.Ldap
37 /// <summary> A single add, delete, or replace operation to an LdapAttribute.
39 /// An LdapModification contains information on the type of modification
40 /// being performed, the name of the attribute to be replaced, and the new
41 /// value. Multiple modifications are expressed as an array of modifications,
42 /// i.e., <code>LdapModification[]</code>.
44 /// An LdapModification or an LdapModification array enable you to modify
45 /// an attribute of an Ldap entry. The entire array of modifications must
46 /// be performed by the server as a single atomic operation in the order they
47 /// are listed. No changes are made to the directory unless all the operations
48 /// succeed. If all succeed, a success result is returned to the application.
49 /// It should be noted that if the connection fails during a modification,
50 /// it is indeterminate whether the modification occurred or not.
52 /// There are three types of modification operations: Add, Delete,
55 /// <b>Add: </b>Creates the attribute if it doesn't exist, and adds
56 /// the specified values. This operation must contain at least one value, and
57 /// all values of the attribute must be unique.
59 /// <b>Delete: </b>Deletes specified values from the attribute. If no
60 /// values are specified, or if all existing values of the attribute are
61 /// specified, the attribute is removed. Mandatory attributes cannot be
64 /// <b>Replace: </b>Creates the attribute if necessary, and replaces
65 /// all existing values of the attribute with the specified values.
66 /// If you wish to keep any existing values of a multi-valued attribute,
67 /// you must include these values in the replace operation.
68 /// A replace operation with no value will remove the entire attribute if it
69 /// exists, and is ignored if the attribute does not exist.
71 /// Additional information on Ldap modifications is available in section 4.6
72 /// of <a href="http://www.ietf.org/rfc/rfc2251.txt">rfc2251.txt</a>
76 /// <seealso cref="LdapConnection.Modify">
78 /// <seealso cref="LdapAttribute">
80 public class LdapModification
82 /// <summary> Returns the attribute to modify, with any existing values.
85 /// <returns> The attribute to modify.
87 virtual public LdapAttribute Attribute
95 /// <summary> Returns the type of modification specified by this object.
97 /// The type is one of the following:
99 /// <li>LdapModification.ADD</li>
100 /// <li>LdapModification.DELETE</li>
101 /// <li>LdapModification.REPLACE</li>
105 /// <returns> The type of modification specified by this object.
107 virtual public int Op
117 private LdapAttribute attr;
119 /// <summary> Adds the listed values to the given attribute, creating
120 /// the attribute if it does not already exist.
124 public const int ADD = 0;
126 /// <summary> Deletes the listed values from the given attribute,
127 /// removing the entire attribute (1) if no values are listed or
128 /// (2) if all current values of the attribute are listed for
133 public const int DELETE = 1;
135 /// <summary> Replaces all existing values of the given attribute
136 /// with the new values listed, creating the attribute if it
137 /// does not already exist.
139 /// A replace with no value deletes the entire attribute if it
140 /// exists, and is ignored if the attribute does not exist.
144 public const int REPLACE = 2;
146 /// <summary> Specifies a modification to be made to an attribute.
149 /// <param name="op"> The type of modification to make, which can be
150 /// one of the following:
152 /// <li>LdapModification.ADD - The value should be added to
153 /// the attribute</li>
155 /// <li>LdapModification.DELETE - The value should be removed
156 /// from the attribute </li>
158 /// <li>LdapModification.REPLACE - The value should replace all
159 /// existing values of the
163 /// <param name="attr"> The attribute to modify.
166 public LdapModification(int op, LdapAttribute attr)