Directory Services

ADSI Extensions

An ADSI extension is a special COM object that enable a developer to extend an ADSI object. Each extension is associated with a specified class in the directory. With this extension model, developers can add methods to give more dynamic meaning to an object. In a traditional directory programming model, an object is accessed by getting and setting the object attributes. Using ADSI extensions, you can add more functionality to a directory object.

The way in which extension methods are implemented depends on the extension writer. An extension writer may even implement a method completely outside the scope of the directory. For example, a developer of backup and restore software plans to extend an object called computer. The developer must create two methods: BackUp and Restore. These methods operate remotely on the physical computer that the computer object in the directory points to. By acting as an extension, the component accesses the ADSI infrastructure and is viewed by ADSI clients as an integral part of the object.

The following guidelines can help you decide if creating an ADSI extension is appropriate:

For ADSI clients, extensions enrich the ADSI programming environment in several ways:

ADSI extensions were designed with the following objectives:

Consider this scenario, a corporate developer or an ISV needs to develop a backup program. This backup program enables an administrator to back up all computers in an organizational unit. With an ADSI extension, the following script is possible.

Dim ou
On Error Resume Next
Set ou = GetObject("LDAP://OU=Sales, DC=Fabrikam, DC=COM")
If Err.Number<>0 Then
	MsgBox("An error has occurred.")
	Err.Clear
	Set ou = Nothing
	Exit Sub
End If

ou.Filter = Array("computer")

For each comp in ou
   Debug.Print comp.Get("networkAddress")
   Debug.Print comp.LastBackUp
   comp.BackUpNow
Next

LastBackUp is a property and BackUpNow is a method that the extension writer provides. The code shows the benefits for both extension consumers and providers. The extension writer does not have to create a new way of filtering, searching, and accessing the directory. The extension consumer does not have to relearn a new programming paradigm. New methods and properties that the extension writer provides are viewed as part of ADSI.

This section describes the following topics: