Update an attribute of all entries using where clause

Home | Tutorials | Compare


This tutorial explains how to update an attribute of all entries within a container using where clause . To run update statement first connect to the Active Directory (To create a new connection please see Connecting to Active Directory remotely )


After successful connection, select the SQL button from the top menu, this will open the sql tab where you can enter the sql statements. You can also create simple sql statement from the right click context menu (Bottom tree pane).



To create a simple sql statement to update all records within a container, Select entry and from right click context menu select 'Update this record and all Children)


Ctrl+v (or paste) to paste the data to the sql window modify the attribute to update, for e.g. to update manager for all the user entries in the container CN=Users,DC=ldapsoft,DC=local where cn not containing any letter 'S' and cn not containing 'Admin and cn no containing 'kr' modify the statement to:

UPDATE CN=Users,DC=ldapsoft,DC=local SET
manager='CN=testuser,CN=Users,DC=ldapsoft,DC=local' where objectClass= 'user' and cn !='%S%' and cn !='%Admin%' and cn !='%kr%'

Change the maximum results to number of records expected or '0' for unlimited. Click 'Run' to run the statement.


active directory run update statement


When you run the statement, A Status dialog will appear which provides the following information

Number of entries to be updated
Status of each entry (Whether the entry update was successful or not)
Total status (how many succeeded how many failed)

Verify the entries to update and click 'Yes'


active directory update using where


The Update Status dialog also gives you the ability to skip all errors or abort the operation after an error.



Warning: Don't run the update statement on attributes with multiple values as it will replace the attribute with new single value. For multiple value please use UpdateReplace statement (For syntax and more information please see the product documentation - search for 'updatereplace' and also 'Difference Between Update, UpdateAdd & Update Replace Statement')


See Also:
Query Active Directory using Select Statements