ADSI Object Methods

You can use the ADSI methods of the IIS Admin Objects to change metabase property values that control your IIS configuration. To configure a specific element of IIS, open the IIS Admin Object that corresponds to the metabase key associated with that element, modify the property values cached in the object, and direct the object to store the modified values in the metabase.

The following ADSI methods are exposed by the IIS Admin Objects, and can be used to set or query metabase properties.

Method Description
Get Retrieves a value for a named property from the object.
GetDataPaths Retrieves the paths to all locations of a metabase property subordinate to a specified starting path.
GetEx Retrieves a value or values for a named single-valued or multivalued property of the object.
GetInfo Reloads the object with property values that exist in the metabase.
GetPropertyAttribObj Retrieves an object that contains the property's attributes. This object can then be used to retrieve individual attributes of ADSI properties.
Put Sets the value for a named property of an object.
PutEx Sets the value or values for a named single-valued or multivalued property of the object.
SetInfo Writes the object property values to the metabase.

The GetInfo method reloads the property values from the metabase into the object. When one of the IIS Admin Objects is created or opened with the GetObject function, its properties are initialized from the metabase. You can refresh these values from the metabase by using the GetInfo method, and overwriting any changes you have made to the property values cached in the object. You then use the Get or GetEx methods to retrieve the object properties and assign these values to variables, and the Put and PutEx methods to modify property values in the object.

The IIS Admin Objects also support the object.property syntax when used with languages such as VBScript or JScript. You can use the SetInfo method to write property values from the object to the metabase. When you call SetInfo, only the properties that you changed in the object are written back to the metabase. If you do not call SetInfo, your changes will not be written to the metabase.

Note   When you bind to the metabase to modify properties in one of the IIS Admin Objects, the metabase is not locked while you are changing property values in the object. Other programs can make changes to values in the metabase after you have retrieved values but before you save them back into the metabase. Your program should minimize the time between retrieving and saving values.

ADSI properties apply only to the object, and non-ADSI properties apply to the metabase. You must use the object.property syntax when retrieving ADSI properties, whereas you can use either the object.property syntax or the ADSI methods such as Get and Put when manipulating metabase properties.

Example

The following sample VBScript code shows how you can use the ADSI methods of the IIS Admin Objects to change values in the metabase, and illustrates the use of metabase property inheritance for efficiency. MyComputer is a placeholder for the name of the computer on which IIS is running.

<% 
  Dim WebServerObj 
  Dim VDirObj 
  Dim WritePerm 
 
  'Open the object for the first virtual Web server root. 
  Set WebServerObj = GetObject("IIS://MyComputer/W3SVC/1/Root") 
 
  'Deny write access for all directories and files 
  'for the server (except those already specifically set)
  'by using the Put method. 
  WebServerObj.Put "AccessWrite", False 
 
  'Save the changed value to the metabase. 
  WebServerObj.SetInfo 
 
  'Get a directory subordinate to the Web server root. 
  Set VDirObj = GetObject("IIS://MyComputer/W3SVC/1/Root/Vdir1/Dir1a") 
 
  'Overwrite the inherited value for write access 
  'by using the dot method equivalent to Put. 
  VDirObj.AccessWrite = True 
 
  'Save the changed value to the metabase. 
  VDirObj.SetInfo 
%>