An ADSI extension is a special COM object that provides a way for developers to extend an ADSI object. Each extension is associated with a specified class in the directory. Developers can give more dynamic meaning to an object by adding methods. In a traditional directory-programming model, objects are accessed by setting and getting properties or attributes.
An extension writer will implement a method that provides additional behavior not initially supplied by the IIS ADSI provider. For example, a company that backs up and restores software wants to extend an ADSI object by creating two methods called BackUp and Restore. These methods will operate remotely on the physical computer pointed to by the ADSI object. By participating as an extension, the methods automatically gain access to the ADSI infrastructure and are viewed by ADSI clients as an integral part of the IIS ADSI provider.
Not all components are appropriate as an ADSI extension. The following guidelines should help you decide if creating an ADSI extension is necessary. Create an extension to:
ADSI extensibility enriches the programming environment in many ways:
Consider the following hypothetical scenario. A network administrator wants to automate a backup procedure for each of her sites. She can accomplish this by writing an extension for the IIsWebService object that includes a backup method. She chooses to call her new method BackUp. She has also created a new property called LastBackUp. The following code is an example of how to call the BackUp method:
Dim objExt as IADsContainer
Set objExt = GetObject("IIS://W3SVC/")
objExt = Array("IIsWebService")
For Each item in objExt
Debug.Print item.Get("ServerComment")
Debug.Print item.LastBackUp
item.BackUp
Next
LastBackUp is a custom property provided by the extension writer, which stores a time and date stamp; BackUp is a custom method provided by the extension writer, which backs up the object represented by item to an archive specified by the administrator.
The preceding code fragment illustrates the benefits for both clients and providers. The extension writer does not have to reinvent a new way of filtering, searching, and accessing the directory. The extension consumer, on the other hand, does not have to relearn a new programming paradigm. New methods and properties provided by the extension writer are viewed as if they are part of ADSI.