Interface IDispatch

A Note about IDispatch

When programmers request the storage and retrieval of properties using the IADs interface method through the IDispatch interface on an instance of the UserObjects class or an ADSI object, they can use a special syntax.  Normally, properties and methods defined for an object must be implemented before compile time.  That is, if an object has a public property called "Name" then the corresponding methods to get and put the value of this property are implemented as part of the coding of the object before it is compiled.  The ADSI objects, (and the UserObjects object), however, support the notion of dynamic properties through the IDispatch interface.  What this means is that programmers can request properties in the object that can change dynamically at runtime.   A programmer can bypass using the "Get/GetEx" and "Set/SetEx" methods, which are static, and simply refer to the desired property as if it belonged to the object.  For VBScript script programmers, this presents a much less cumbersome syntax, since all method and property calls act via the IDispatch interface.

Example:

Static sytax (clear)

UserObjects.Get("givenName")

Dynamic property syntax (may be confusing, but is easy)

UserObjects.givenName

Both of these calls would return the same property from the directory service.

CAUTION   When using the dynamic property syntax, one must be careful to avoid name collisions with bona fide properties of the object.  These "real" properties of the object always take precedence over data fetched from a directory service.  For example, any directory service properties with the names "GUID," "Parent," or "Name" would conflict since these names are used to store information about the object itself, and must be returned when requested.  In such cases, one must use the "Get" and "Set" methods for these properties.


© 1997-1998 Microsoft Corporation. All rights reserved.