Export (0) Print
Expand All

Step 3: Committing to Active Directory

Microsoft® Windows® 2000 Scripting Guide

Anytime you make a change, whether by creating an object or by writing a value to an attribute, you must save the changes to the directory by calling the SetInfo method. An ADSI script will run properly even if you do not commit changes, but if you do not commit changes, anything that the script did in the local property cache is lost after the script ends. For more information about the local property cache, see "Step 2: Performing a Task" in the preceding section.

The act of saving an object to the directory is called committing. Committing an object to Active Directory is analogous to saving a document that you created in a word processing application. The act of saving the document writes the data in memory to a location on your hard disk, just as the act of calling the SetInfo method writes the data in memory (the local property cache) to Active Directory.

The code for committing an object to the directory includes the variable name of the object, a dot, and the SetInfo method call. Previously, you learned that Create, Get, Put, and Delete are method calls to complete a task. SetInfo is simply another method call whose sole task is to save objects or attributes to a directory service. Notice that this method call is the last line in all script examples in the previous Create and Modify task sections.

The code listings in "Reading Attributes of Directory Service Objects" earlier in this chapter do not contain the SetInfo method because these tasks simply bind to an object in Active Directory and read an attribute of an object. The object is not modified, so there is no need to save any changes to Active Directory. This is analogous to reading a word processing document without making any changes to it. While you can save the document to the disk, there is no reason to do so.

The code listings in "Deleting Directory Service Objects" earlier in this chapter do not contain the SetInfo method because the Delete method deletes objects from Active Directory immediately.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft