Difference Between Update, UpdateAdd & Update Replace Statement

 

Main Difference:

Update Statement replaces the existing attribute with new attribute value, multiple values will be replaced with new single value

UpdateAdd adds values to the exiting attributes, creating the attribute if it does not already exists (Requires Version 3.2 or better)

UpdateReplace replaces the existing attribute value, if found (Requires Version 3.2 or better)

 

When to use Update Statement:

When attribute is single value attribute like 'userpassword' and you want to replace the existing value. If you use the Update statement for attributes with multiple values it will replace the current value(s) with the new value. Please use UPDATEREPLACE for attributes with multiple values.

 

Update Statement with Single Value Attribute, before and after running the following update statement:

UPDATE cn=testuser3,ou=testusers,o=stooges set userPassword='newpassword'

 

Update ldap Attribute   Ldap Update Attribute

 

Update Statement with Multi Value Attribute, before and after running the following update statement:

UPDATE cn=testuser3,ou=testusers,o=stooges set description='newdescription'

Update Ldap AttributeUpdate Ldap Attribute

 

With 3.2 release you can now assign multiple values to update statement, to assign multiple values seperate them by comma like

UPDATE cn=testuser3,ou=testusers,o=stooges set description='newdescription', description='newdescription2'

 

 

When to use UpdateAdd Statement:

When you want to add a new value to an exiting attribute, creating an attribute if it does not exist

Before and after snapshot after running the following UPDATEADD statement:

UPDATEADD cn=testuser1,ou=testusers,o=stooges set description ='description2'

 

Update Replace Ldap Attribute            Update Add ldap attribute

 

When to use UpdateReplace Statement:

When you want to replace a specific attribute value, if an attribute is single value attribute the update and update replace results will be same but if the attribute has multiple values then UpdateReplace will only replace the specified value.

Before and after snapshot after running the following UPDATEREPLACE statement:

UPDATEREPLACE c n=testuser1,ou=testusers,o=stooges set description ='description3' where description ='description2'

Update Replace Ldap Attribute            Update Replace Ldap Attribute

 

 

Related Links:

Update Statement

UpdateAdd statement

UpdateReplace statement

Update statement examples

 


Ldapsoft Home page LDAP Admin Tool Home Page