Modifying Attributes with ADSI

To modify attribute values, ADSI provides the IADs.Put and IADs.PutEx methods. These methods modify the data on the client-side cache. The IADs.SetInfo method must be called to commit the changes to the directory.

Note

When multiple attribute changes are committed in a single call to IADs.SetInfo, if any single attribute cannot be modified, none of the attributes will be modified. For example, if you modify the sn and givenName attributes and clear the telephoneNumber attribute of a user object without any subsequent calls to the SetInfo method, the changes are entered when you call SetInfo. If one or more of the modifications are not allowed and therefore cannot be performed, then none of the collective modifications made to the attributes are entered during the call to SetInfo.

 

The IADs.Put method takes an attribute name and a variant parameter. Use this method to set attributes that contain both single and multiple values.

The IADs.PutEx method provides control over operations on multi-valued attributes. You can append, delete, update, and clear existing values. The IADs.PutEx method always expects a variant array of attribute values. However, you can use this method to set an attribute with a single value as well.

The IADs.PutEx method uses the operations specified by the ADS_PROPERTY_OPERATION_ENUM enumeration.