Method and system for scripting for system management information6493719Abstract A method and system that simplify the management of enterprise network devices and information through the use of scripts and a scripting object model. An API is provided that transforms scripts passed from a scripting engine into the existing "low-level" COM syntax required for accessing system management object information. A scripting engine interprets a script and works with the API to translate script instructions into the COM method calls needed to directly access properties and methods of CIMOM objects from a script. Other aspects related to scripting are handled, including collections, events, monikers and security. Collections enable a set of objects to be serviced iteratively, for example, to manipulate or retrieve properties for a set of resources in simple loop. Events enable queries to be made asynchronously, such that calls return immediately and complete via event notifications. Monikers enable the simplification of strings in the script, by providing for shorthand definitions to represent a sequence of instructions in a single string. Security is provided, by emulating the ability to set security. Claims What is claimed is: Description FIELD OF THE INVENTION
{
Volume = "DISKC";
FileSystem = "XFS";
TotalCapacity = 240000000;
Freespace = 180000000;//Dynamically supplied by provider
};
Note that since the FreeSpace parameter is highly volatile, in a typical implementation the value would be supplied by a provider 68, rather than being a stored or static value. The CIMOM 64 is capable of retrieving both the static and dynamic information from various sources including the CIM database 72 and/or appropriate providers such as 68.sub.2, and returning the object instance to the client process (application) 62. The CIMOM 64 is capable of receiving potentially high level SQL queries, decomposing those queries as necessary, and communicating with a variety of sources, possibly in a series of very primitive operations, to produce a result. The operations are transparent to the client process 62, as the result is returned in the same manner regardless of the sources that supplied the information. For example, a query such as--select from LogicalDisk where FreeSpace<20000000--intends to have returned only instances that meet the less than twenty megabyte criteria, and not all instances of the LogicalDisk class. If the provider or providers of this information are unable to limit their retrieval based on this criteria, the CIMOM 64 provides the correct result set by a post-retrieval filtering operation. The CIM object manager thus performs operations that complement the capabilities of providers in order to uniformly render managed objects to management applications. Because some providers have substantially more capabilities than other providers, the CIMOM 64 attempts to operate each provider with its maximum capabilities, lowering its level for requesting information from a provider until the provider can satisfy the request, e.g., by reducing the complexity of a query for that provider. SCRIPTING FOR SYSTEM INFORMATION As described above, the CIMOM 64 provides interfaces for accessing via a COM object to query for and otherwise access system information. The present invention essentially wraps those interfaces to present them as a suitable object model for scripting in a uniform way that is usable by contemporary scripting languages. The object model and scripting API 74 (application programming interface) for wrapping the interfaces are described below. Thus, in accordance with one aspect of the present invention, there is provided a method and system that transform script written in a straightforward, natural syntax into the COM calls and appropriate syntax needed to directly access properties and methods of CIM (or WBEM, i.e., Web-based Enterprise Management) objects. To this end, as shown in FIG. 3, a scripting API 74 is provided whereby a scripting engine 76 interpreting a script 78 calls the API 74 to access the information. The API 74 may be implemented as a dynamic link library (DLL). By way of example, to directly access a CIM object's property such as the free space on a disk volume named "C:," a script may simply request: obj=Svc.Get("Disk=""C:""") value=obj.FreeSpace. As can be readily appreciated, this straightforward two-line request intuitively matches what a scriptwriter desires, i.e., the retrieval of an object, and then the value of a property on that object. The more complex transformation to that required by the CIMOM 64 is performed in the scripting API 74. Note that the accessible objects and properties are known to the scriptwriter from a published schema. Further, in addition to retrieving property values, note that CIM objects may have property values set therefor, and CIM objects may have methods called via the script. In the above example, the first line is translated to create a locator object and obtain a services object from the locator object by calling a "ConnectServer" method of the locator object. Note that this script fragment assumes that a "services" object has already been created and that a reference to it is stored in the variable called "Svc". Then, the scripting API 74 returns an identifier corresponding to the svc.Get function to the scripting engine 76. To this end, the scripting API 74 analyzes the string "svc.Get" to determine that it corresponds to a set of interfaces having a static value, and looks up this value (i.e., "7") from a type library 80 of the interfaces. Note that from the perspective of the scripting engine 76, the scripting engine 76 simply passes in a string and receives an ID in return. These above actions are generally represented in FIG. 4 by circled numerals one (1) through five (5), wherein beginning at numeral (1), the scripting engine 76 interprets the script--obj=Svc.GetObject("Disk=C:"). At circled numeral (2), the scripting engine 76 calls the scripting API 74 via the well-known Idispatch mechanism, passing it the "Svc.GetObject" string as a parameter seeking an ID for this function. The scripting API 74 recognizes this string as having a static value therefor stored in the type library 80, which it looks up and retrieves as represented in FIG. 4 by circled numerals (3) and (4). The scripting API 74 returns the ID (equal to seven) to the scripting engine 76 as represented via circled numeral (5). Once the scripting engine 76 has the ID for this function, the scripting engine 76 uses the value to call the corresponding GetObject method via the well-known "Idispatch::Invoke" function call, as represented in FIG. 4 by circled numeral (6). A parameter of "Disk=C:" is passed to identify the desired object. When the scripting API 74 receives this call, it recognizes the call as corresponding t o a static parameter, (via the ID's most significant bit value of zero, as described below), whereby the call is passed essentially as is (circled numeral (7) to a well-known automation DLL 82 (OLEAUT32.dll, by calling IDispatch::Invoke on the automation DLL 82 with the same parameters. From there, the object ID of the "Disk=C:" object (class disk) is returned via the scripting API 74 and scripting engine 76 to the script 78 (e.g., a cached memory location 84 associated with the script 78 by the scripting engine 76) for use in subsequent script interpretations, as represented in FIG. 4 by circled numerals (8), (9) and (10). FIG. 5 represents a similar process to obtain the FreeSpace property value. Note that this time, however, the FreeSpace property does not have a statically defined identifier associated therewith in the type library 80. Nevertheless, as will be described below, the scripting engine 76 will merely pass in a string and receive an appropriate ID via the IDispatch mechanism, and then via the IDispatch::Invoke call, will pass in the ID and receive the desired property value. Thus, the scripting engine 76 is relatively straightforward to implement. Moreover, the single variable is compatible with limitations of some scripting languages, (e.g., Jscript), which, for example, cannot be written in a manner that enables them to (upon interpretation) directly generate the syntax required by COM. In FIG. 5, the object ID is known, as is the ID for the GetProperty function, in the manner described above. Note that the ID for the GetProperty function may be obtained in the same manner as the static GetObject function ID. As a result, when the next script line is interpreted as requesting value=obj.FreeSpace at circled numeral (1), the scripting engine 76 can call the scripting API 74 with the appropriate information to obtain the value of FreeSpace. More particularly, as represented in FIG. 5 by the circled numeral (2), the scripting engine 76 passes the string "FreeSpace" to the scripting API 74. Upon analyzing this string, the scripting API 74 recognizes it as corresponding to a property of the class schema 86 for the "disk" class. In keeping with the invention, the scripting API 74 dynamically generates an identifier for the FreeSpace property. For example, the scripting API 74 may number the identifier based on the alphabetic order of the property in the disk class. The scripting API 74 also sets the high bit of the (thirty-two bit) ID so as to mark it as dynamically generated (as opposed to static). In FIG. 5, circled numerals (3) and (4) represent the retrieving of the corresponding number (e.g., alphabetic order) from the class store, wherein 0000 represents the high bits 31 through 28, the ellipsis ( . . . ) represents bits 27 through 3, and 101b represents bits 2 through 0 (in binary). Thus, in the hypothetical example herein, the FreeSpace property has a value of five, which is returned to the scripting engine 76 as the ID for FreeSpace, after setting the most significant bit (1000 . . . 10b) as represented in FIG. 5 by circled numeral (5). Note that this makes the scripting API 74 extensible, as the scripting API 74 can provide IDs for new objects added to the schema 86 over time. Once the scripting engine 76 has the ID for this property, the scripting engine 76 uses the ID to call the corresponding GetProperty method via the well-known "Idispatch::Invoke" function call, as represented in FIG. 5 by circled numeral (6). The object ID for Disk C: is passed as a parameter to identify the desired object, as is the value of the FreeSpace ID that was just returned. When the scripting API 74 receives this call, it recognizes the call as corresponding to a dynamic parameter, (via the ID's most significant bit, set to one), whereby the ID is used to lookup the correct property in the disk C: object, i.e., the FreeSpace property. Note that from the above example, this mapping of a string to an ID, and then reverse mapping the ID to the property may seem redundant, however IDs are more efficient than string interpretation, and the scripting API 74 does not assume the purpose for which the scripting engine 76 is requesting the ID. Moreover, the scripting engine 76 may cache returned IDs for numerous queries and the like without having to repeatedly ask for the same ID, e.g., a script may request the FreeSpace of disk C: more than once, yet the scripting engine 76 only need obtain the various IDs once. Nevertheless, it is feasible for the scripting API 74 to cache an ID/property (or ID/method) relationship in anticipation of its subsequent use, to thereby speed up the reverse mapping process. It is also feasible for the scripting engine 76 to pass a string and receive a result from the scripting API 74 without ever receiving the ID, since the scripting API 74 could use the IDs to generate its own Invoke calls, essentially handling some of the functionality performed by the scripting engine 76. With the above information, the scripting API 74 contacts the CIMOM 64 (via the proxy 68) using the appropriate COM syntax--Obj.GetProperty("FreeSpace", value, flavor)--, whereby the CIMOM 64 returns the value, as represented by circled numerals (9)-(12) in FIG. 5. In this manner, a script 78 is able to obtain information from the CIMOM 64 using a straightforward syntax in a very intuitive manner, i.e., an "object.property" (dot notation) syntax. The scripting API 74 handles the translation to the syntax understood by the CIMOM 64, FIGS. 6 and 7 are flow diagrams that summarize the processes performed by the scripting API 74 and described above. In FIG. 6, the scripting API 74 is given a string from the scripting engine 76 via the IDispatch mechanism, as represented at step 600. At step 602, the scripting API 74 analyzes the string and determines whether it corresponds to a static method or dynamic method or property. If static, an ID corresponding thereto is returned from the type library 80 at step 604. If dynamically generated, step 606 is instead executed to generate the ID, such as from its alphabetic property or method position in the object class, and also by setting the most significant bit of the ID. Whether static or dynamic, the ID is returned to the scripting engine 76 at step 608. In FIG. 7, the ID is known, and passed from the scripting engine 76 via the IDispatch::Invoke call, as represented at step 700. At step 702, the ID is evaluated to determine whether it corresponds to a static method or dynamic method or property. If static, the call is passed to the automation DLL 82 (by calling IDispatch::Invoke of the automation DLL 82 with the same parameters) at step 704, and the result returned at step 710. If dynamically generated, step 706 is instead branched to by step 702, whereby the property is determined by reverse mapping from the ID (after masking off the most significant bit) as described above. The CIMOM 64 is then called at step 708 to obtain the property value, and the result returned at step 710. THE WBEM SCRIPTING OBJECT MODEL FIG. 8 represents the principal objects and their relationships within the WBEM Scripting Object Model 90, wherein the boxes within the diagram represent objects in the scripting model 90. The Event Sink, Locator, NamedValueSet, Service, Last Error, CIM Object and Object Path objects represent objects which can be created directly by the scripting API 74. Note that the Locator object is created using conventional methods for creating coclasses, while the other objects can be created using Moniker display names, described below. Further, note that the SWbemNamedValueSet, SWbemObjectPath, SWbemLastError and SWbemSink objects are also coclasses and accordingly may be directly created. The NamedValueSet, CIM Object Collection, Privilege Collection, Property Collection, Qualifier Collection and Method Collection objects represent Automation Collection objects. In FIG. 8, an arrow from one object (e.g., the Locator Object) to another object (e.g., the Service Object) indicates that the object (the Locator object) can obtain the other object (the Service object) from a call to that object (the Locator object) via the Scripting API 74 relationship. The Locator Object represents a WBEM locator, and is directly creatable as a coclass. The locator object has only one method, ConnectServer, which is the means of obtaining a Service object. It has the following properties:
Name Type Purpose Access
Security.sub.-- Security Return the Security Read-
object for this only
Locator object
This property allows security attributes to be associated with a SWbemLocator, used for the purposes of defining Privilege on operating systems prior to the first ConnectServer call. As can be appreciated, security is important because a user Can access objects in CIMOM for example, to format a hard drive. Accordingly, CIMOM limits access based on user identity, and also audits operations. Further, sensitive information is sometimes exchanged via DCOM, whereby encryption is used, and sometimes users need to switch on certain privileges to perform certain operations. As described below, because there is no way to directly expose the IWbemServices security interface of CIMOM to a script, the scripting API 74 emulates the ability to set security via script by providing SWbemServices, a scriptable version of IWbemServices, to expose security properties. Moreover, security emulated for one object may be applied across other objects, e.g., if one object is encrypted, the script does not have to specify others for encryption, as it is performed therefor. As also described below, the extension to security further enables a scriptwriter to specify privilege information in a timely manner. Note that the Impersonation and Authentication properties of SWbemSecurity are not directly applicable to SWbemLocator (there is no remote proxy). However they will be propagated to any child SWbemServices objects in the normal manner, thereby providing a useful mechanism for defining global settings for these properties. The Event Sink Object represents a sink for WBEM events, and is used for asynchronous API calls, described below. It is directly creatable as a coclass. It supports the following methods:
Name Purpose
Cancel Cancel all outstanding asynchronous
calls bound to this object instance.
The sink supports the following events:
Name Purpose
OnObjectReady Called when CIM Object returned from
asynchronous call
OnCompleted Called when asynchronous call
completed.
OnProgress Called to report progress of
asynchronous call.
OnPut Called when CIM Object is saved
following an asynchronous Put call.
The Service Object represents an authenticated connection to a namespace. It has a single automation property:
Name Type Purpose Access
Security.sub.-- Security Return the Security Read-
object for this write
Services object
The Services object supports the following automation methods, in both synchronous and asynchronous form:
Name Purpose
Get Retrieve a CIM Class or Instance.
Delete Delete a CIM Class or Instance.
SubclassesOf Enumerate subclasses of a CIM Class.
InstancesOf Enumerate instances of a CIM Class.
ExecQuery Execute a WQL query.
ExecNotificationQuery Execute a WQL notification query,
returning an Event Source.
ExecMethod Execute a method on a CIM Instance
or Class.
AssociatorsOf Retrieve associators of a CIM
Instance or Class.
ReferencesTo Retrieve references to a CIM
Instance or Class.
The Event Source Object represents a source of events obtained from WBEM, and is returned by the ExecNotificationQuery method of the Service object. It has a single automation property:
Name Type Purpose Access
Security.sub.-- Security Return the Security Read-
object for this Event write
Source object
It supports the following methods:
Name Purpose
NextEvent Get the next event from the source
(or timeout)
The Object Path Object is a helper object that can be used to construct WBEM object paths without the user requiring to know the details of the Object Path syntax. This object supports the following automation properties:
Name Type Purpose Access
Path (DEFAULT) BSTR The full WBEM path Read-
write.sup..dagger-dbl.
RelPath BSTR The relative (to Read-
namespace) path write.sup..dagger-dbl.
Server BSTR The server name Read-
write.sup..dagger-dbl.
Namespace BSTR The namespace path Read-
write.sup..dagger-dbl.
ParentNamespace BSTR The parent namespace Read-
only
DisplayName BSTR The moniker-style Read-
display name write.sup..dagger-dbl.
Class BSTR The name of the Class Read-
write
IsClass BOOL Whether the path Read-
addresses a class only
IsSingleton BOOL Whether the path Read-
addresses a singleton only
instance
Keys Named Value The set of key value Read-
Set bindings for this path only
Security.sub.-- SWbemSecurity Defines the Security Read-
component of the path. only
Locale BSTR Defines the Locale Read-
component of the path
write.sup..dagger-dbl.
Authority BSTR Defines the Authority Read-
(Principal) component
write.sup..dagger-dbl.
of the path
Note that the NamedValueSet object is immutable, but can be cloned to provide a mutable copy. Further, note that when the SWbemObjectPath is returned as the Path_ property of a SWbemObject, the above Read-Write properties marked (.dagger-dbl.) become Read-Only. Read-only means that the Property cannot be set, but methods can be called on the collection which will modify the contents thereof. Also, the term DEFAULT is applied to a property or method to indicate that it is the "Dispatch Default" property/method on an automation object. This means that the property name can be omitted, e.g., the following VBScript fragment "WScript.Echo MyObjectPath" where MyObjectPath is an Object Path object, would output the value of the Path property of an Object Path. The Security_ property allows security attributes to be associated with an SWbemObjectPath, whereby scriptwriters may build object paths containing Privilege override information without requiring the scriptwriters to know how to build strings from scratch. Note that this property does not affect the runtime security behavior of the SWbemObjectPath of which it is a member, but is there solely to allow security information to be specified easily when defining a path. Further, note that when the SWbemObjectPath is returned as the Path_ property of an SWbemObject, the Security_ property of the object path is immutable. This is consistent with the immutability of the Path_ property value currently enforced by the scripting API 74. The Object Path Object supports the following methods:
Method Purpose
SetAsClass Coerce the path to address a Class
SetAsSingleton Coerce the path to address a Singleton Instance
The Named Value Set Collection is a collection object, each of whose elements is a CIM Named Value. A collection object is a type of Automation Object that provides built-in support for certain iterative constructs used by VB and VBScript. For example, a collection can be used in a VB "for each I in C" statement. Use of collections makes for a simpler and more natural programming style. The Named Value Set Collection is used to model a collection of named values that may be passed as additional information to a method of the Services or Locator objects, and it supports the Collection properties Count and _NewEnum. It also supports the standard Collection methods (Add, Item and Remove), as well as the DeleteAll method. The Item implementation allows the use of the value name as the indexing mechanism for the collection, e.g., it is possible to use WbemNamedValueSet("foo") in VB or VBScript as a concise means of referring to the element of the WbemNamedValueSet whose name is "foo," (i.e., as a shorthand for WbemNamedValueSet.Item("foo")). The GetNames method from the COM API is not supported, as this can be accomplished using other API calls, and thus is omitted in the interests of keeping the API as small and as simple as possible. The Named Value Object is used to model a named value (a combination of a name and a VARIANT value). Named values are collected in a WbemNamedValueSet object. The Named Value object supports the following automation properties:
Name Type Purpose Access
Name BSTR The name of the Read-
value. only
Value VARIANT The value. Read-
write
The CIM Object Collection is a collection object, each of whose elements is a CIM Object. It is used to model the result set associated with an enumeration or query, and supports the Collections property _NewEnum and Count. The CIM Object Collection supports the Collection method Item, where the index supplied is the relative path of the object, and further supports the Security_ property, which returns the Security object for the Collection. It does not support the optional Collection methods (Add and Remove). This object also supports the WBEM Clone method. The CIM Object is used to represent a single CIM Instance or Class. CIM properties (those which would appear in a Managed Object Format (MOF), but not WBEM system properties and methods, are exposed in one of two ways. A first way is directly via the "dot" (object.property or object.method) notation as automation methods and properties of this interface. This is extremely convenient for scripts written to manipulate specific CIM objects. A second way is indirectly, via the property and method collections available from this object, required for "schema browser"-type scripts which deal with objects generically. The CIM Object supports the following automation properties (wherein the trailing "_" is used to help guarantee uniqueness of names):
Name Type Purpose Access
Derivation.sub.-- SAFFARRAY of An array of class Read-
VARIANT names (possibly only
empty) describing
the derivation
hierarchy. The
first (lowest-index)
member of the array
is the _SUPERCLASS,
and the last is the
DYNASTY.
Path.sub.-- Object Path Object Location and naming Read-
(section 0) information for the only
CIM Object.
Qualifiers.sub.-- Qualifier Object-level Read-
Collection qualifiers only
Properties.sub.-- Property Object properties Read-
Collection only
Methods.sub.-- Method Collection Object methods Read-
only
Security.sub.-- Security Return the Security
object for this
Object
Note that the single Derivation_ automation property encompasses three "system" properties exposed in the C++ COM API, namely _DERIVATION, _DYNASTY and _SUPERCLASS. Further, note that the single Path_ automation property encompasses six "system" properties exposed in the C++ COM API--_GENUS, _CLASS, _SERVER, _NAMESPACE, _RELPATH and _PATH. Following the paradigm of that API, only the Class automation property of this Object is write-able. It also should be noted that "system" properties are exposed in the scripting API 74 as automation properties of the CIM Object, rather than true CIM properties. In addition the _PROPERTY_COUNT system property is exposed as the standard Count property of the Property Collection Object (section 0). The CIM Object supports the following methods (wherein the underscore is again used for uniqueness), and wherein the methods marked with an asterisk have additional asynchronous (described below) equivalents:
Name Purpose
Clone Create a copy of this object.
GetObjectText.sub.-- Retrieve MOF representation of this
object.
SpawnDerivedClass.sub.-- Create a subclass object.
SpawnInstance.sub.-- Create an instance Object.
CompareTo.sub.-- Compare with another Object.
Put_* Submit the object to CIMOM
Delete_ * Delete the object from CIMOM
ExecMethod_ * Execute a method on the object
Instances_ * Enumerate instances of the object (object
is a class)
Subclasses_ * Enumerate subclasses of the object
(object is a class)
Associators_ * Enumerate associators of the object
References_ * Enumerate references to the object
The CIM Object serves a dual purpose, namely to allow the user to specify CIM properties and methods via the natural dot "." notation as described above, and to give users access to meta-information (such as the class name). Because there is a potential for name clashes between automation properties and methods which model meta-information, and those that model corresponding CIM properties and methods. In order to avoid this clash, certain conventions have been adopted, i.e., meta-information names have an appended single underscore ("_") character (e.g., Qualifiers_). Note that the use of the underscore as the final character in a WBEM element name is disallowed in at least one implementation. The Last Error Object is a CIM Object that is directly creatable, and may be used to return the last WBEM extended error object (of any) generated on the current thread (in all the current scripting environments there is only one thread). The object has read-once semantics, i.e., it is cleared after reading. The Last Error Object is used to provide similar functionality to the GetLastError call in the Win32 API. The Qualifier Collection Object is a collection object, each of whose elements is a Qualifier Object. It represents the set of qualifiers attached to a CIM element (class, instance, property or method). It supports the standard Collection methods (Add, Item and Remove), and the standard Collection properties (Count and _NewEnum). The Item implementation allows the use of the qualifier name as the indexing mechanism for the collection. The GetNames method from the COM API is not supported, as this can be accomplished using other API calls and has thus been omitted for simplicity. The Qualifier Object represents a qualifier, and has the following automation properties:
Name Type Purpose Access
Name BSTR Qualifier name Read-only
Value (DEFAULT) Variant Qualifier value Read-write
IsLocal BOOL Whether the qualifier Read-only
is local to the
owning object, or has
been propagated
PropagatesToSubclass BOOL Controls the Read-write
propagation behavior
to subclasses
PropagatesToTnstance BOOL Controls the Read-write
propagation behavior
to instances
IsOverridable BOOL Determines whether Read-write
the qualifier may be
overridden when
propagated
Origin BSTR Originating class Read-only
name
IsAmended BOOL Whether the Qualifier Read-only
has been amended
(localized) using a
merge operation
The Property Collection Object is a collection object, each of whose elements is a Property Object. It represents the set of properties attached to a CIM element (class or instance). It supports the standard Collection methods (Add, Item and Remove), and the standard Collection properties (Count and NewEnum). Note that the Add and Remove methods are not supported on an Instance. The Item implementation allows the use of the property name as the indexing mechanism for the collection. The GetNames method of the COM API is not supported, as this can be accomplished using other API calls, and thus has been omitted in the interests of keeping the API as small and as simple as possible. The Property Object represents a property. It has the following automation properties:
Name Type Purpose Access
Name BSTR Property name Read-only
Value Variant Property value Read
(DEFAULT) write
IsLocal BOOL Whether the property Read-only
is local to the
owning object, or has
been propagated
Origin BSTR Originating class Read-only
name
Qualifiers Collection Property qualifiers Read-only
CIMtype WbemCimtypeEnum CIM type of property Read-only
(not including the
"array"-ness)
IsArray BOOL Determines whether Read-only
the property is an
array type
The Qualifiers_ collection is a Qualifier Collection Object (the trailing underscore has been retained for consistency with the CIM Object naming of the analogous automation property). Note that Read-Only means that the automation property is read-only, but not necessarily the contents of that property, in the case that the property represents a collection. The Method Collection Object is a collection object, each of whose elements is a Method Object. It represents the set of methods attached to a CIM element (class or instance). Due to a feature of the underlying WBEM COM API, this collection is always empty on an instance. In addition, the Add method is not supported on an instance. The Method Collection Object supports the standard Collection method Item. The Add and Remove methods are not supported, as this is essentially a read-only collection. The Item implementation allows the use of the method name as the indexing mechanism for the collection. The standard Collection properties _NewEnum and Count are supported. The Method Object represents a method, and has the following automation properties:
Name Type Purpose Access
Name BSTR Method name Read-only
Origin BSTR Originating class name Read-only
Qualifiers.sub.-- Qualifier Method qualifiers Read-only
Collection
InParameters CIM Object In parameters definition Read-only
OutParameters CIM Object Out parameters definition Read-only
Note that the qualifiers_ collection is a Qualifier Collection Object (the trailing underscore has been retained for consistency with the CIM Object naming of the analogous automation property). The Security Object represents the DCOM security attributes on an Object, exposed as a property on any Object in the API that supports remote access to Windows Management services. Currently the object types that support remote access are Locator (SWbemLocator), CIM Object (SWbemObject), CIM Object Collection (SWbemObjectSet), Services (SWbemServices) and Event Source (SWbemEventSource). The above objects surface the Security object as a property called Security_. This subset of objects is referred to as "Securable objects". The Security object supports the following automation properties:
Name Type Purpose Access
ImpersonationLevel WbemImpersonat Defines the DCOM Read-
ionLevelEnum imperscnation write
level for the
object
AuthenticationLevel WbemAuthentica Defines the DCOM Read-
tionLevelEnum Authentication only
level for the
object
Privileges SWbemPrivilege Defines the set read-
Set of Privilege only
overrides in
effect for
operations on
this object.
Read only for privileges means that the property cannot be set, but methods can be called on the collection which will modify the contents thereof. In the case of ImpersonationLevel and AuthenticationLevel, the value of the property is an enumeration type, the members of which correspond precisely to the values supported by the standard DCOM security method IClientSecurity::SetBlanket. Internally the SWbemPrivilege object will store the LUID (Locally Unique Identifier) of the Privilege, for efficiency of implementation as this is the means by which the Privilege is identified to AdjustTokenPrivilege ( ). Note that the same propagation rules apply to this property as to other properties of the SWbemSecurity, i.e., the Privilege set is copied from object A to object B as a result of a Scripting API 74 call on object A that returns object B; thereafter, the Privilege Set of object B is independent of object A. The API exposes these security attributes because there is no "generic" support for DCOM security configuration in an automation environment that is analogous to the IClientSecurity interface provided by DCOM in "raw" non-automation environments. Also, impersonation is an important feature of Windows Management that requires client-side configuration to work correctly. Authentication, and in particular the ability to request encryption of sensitive data when remoted via DCOM, is a useful feature for automation applications. The security settings on any securable object are determined by applying simple propagation rules, i.e., for an SWbemServices object obtained from a SWbemLocator.ConnectServer ( ) call, the settings are those determined from the settings on SWbemLocator, if these have been specified in script, or from the current DCOM configuration of the local host. For an SWbemServices or SWbemObject object obtained from a Moniker display string, the settings are as determined by the moniker display string, if the string includes security settings, otherwise, as determined from the current DCOM configuration of the local host. For a securable object obtained from a method call on another API Object, the security settings are those propagated from the last securable interface used in the propagation chain. By way of example, consider the following operational sequence: 1. Create an SWbemLocator object. 2. Call SWbemLocator.ConnectServer to create an SWbemServices object. 3. Modify the security configuration of the SWbemServices using its Security_property. 4. Call SWbemServices.Get to obtain an SWbemObject object. The SWbemObject obtained in step (4) will be created with the same security settings as were applied to the SWbemServices object in step (3). For a securable object returned from a method call on another API Object, the security settings conferred on the returned securable object are independently modifiable from those on the object on which the method call was made. For example, referring back to the example in the previous bullet, changes to the Security_ property of the SWbemObject obtained in step (4) have no effect on the Security_ property of the SWbemServices object obtained in step (2). The table below describes the API calls that result in propagation of security settings:
Method Call or Event New Securable
Parent Object Callback Object
SWbemLocator ConnectServer SWbemServices
SWbemservices Get SWbemObject
SWbemServices SubclassesOf SWbemObjectSet
SWbemServices InstancesOf SWbemObjectSet
SWbemServices ExecQuery SWbemObjectSet
SWbemServices ExecNotificationQuery SWbemEventSource
SWbemServices AssociatorsOf SWbemObjectSet
SWbemServices ReferencesTo SWbemObjectSet
SWbemSink OnObjectReady SWbemObject
SWbemObject Instances SWbemObjectSet
SWbemObject Subclasses SWbemObjectSet
SWbemObject Associators SWbemObjectSet
SWbemObject References SWbemObjectSet
SWbemEventSource NextEvent SWbemObject
SWbemObjectSet Item SWbemObject
SWbemObjectSet Next SWbemObject
For SWbemSink, the Parent securable object is the object that returned this Sink from an asynchronous call (this will be either an SWbemServices or SWbemObject). The Privilege Object is not directly creatable, and supports the following properties:
Name Type Purpose Access
Identifier WbemPrivilege The Wbem id of this read-
LevelEnum privilege, the "key" of the only
Privilege from the user's
perspective.
Name BSTR The NT Privilege Name (e.g. read-
SeShutdownPrivilege). only
DisplayName BSTR The Privilege DisplayName read-
(e.g. "Shut down the only
system"), useful for UI.
IsEnabled BOOL Whether the Privilege is to read-
be enabled or disabled from write
the Token.
Internally the SWbemPrivilege object will store the LUID (Locally Unique Identifier) of the Privilege, for efficiency of implementation as this is the means by which the Privilege is identified to AdjustTokenPrivileges ( ). Other privileges may include SeUndockPrivilege, SeSyncAgentPrivilege and SeEnableDelegationPrivilege. The Privilege Collection Object is a collection of SWbemPrivilege objects, and supports the Collection properties Count and _NewEnum. It also supports the standard Collection methods (Add, Item and Remove). The Item implementation allows the use of the Privilege identifier (of type WbemPrivilegeEnum) as the indexing mechanism for the collection. It also supports the DeleteAll method, which removes all Privileges from the Collection. The Add method will accept a WbemPrivilegeEnum value and BOOL (initial state) as parameters. In addition the AddAsString method will accept a standard NT/Win2K privilege string (e.g. "SeDebugPrivilege") and BOOL (initial state) as an alternative means of specifying the parameters. The scripting API 74 includes other features, as described hereinafter: Object Creation using ProgIDs is supported for the following objects:
Prog ID Object Returned
WbemScripting.SWbemLocator SWbemLocator
WbemScripting.SWbemNamedValueSet SWbemNamedValueSet
WbemScripting.SWbemObjectPath SWbemObjectPath
WbemScripting.SWbemLastError SWbemLastError
WbemScripting.SWbemSink SWbemSink
In addition the type library 80 for the WBEM Scripting API 74 has the assigned name WbemScripting. The means by which objects are created varies with the programming environment. For example, in VB 5.0, The following syntax can be used to create an object: Dim Locator as New WbemScripting.SWbemLocator. In addition, the CreateObject call can be used: Dim Locator As SWbemLocator `optional Set Locator=CreateObject("WbemScripting.SWbemLocator") In VBScript 3.0, VBScript supports the CreateObject function: Set Locator=CreateObject("WbemScripting.SWbemLocator") In JScript 3.0, JScript supports the ActiveXObject function: var locator=new ActiveXObject("WbemScripting.SWbemLocator") CPAN Perl for Win32 supports the OLE CreateObject function: use Win32::OLE; $locator=Win32::OLE->Createobject(`WbemScripting.SWbemLocator`); In WSH (Windows Scripting Host) 1.0, the WScript object supports the CreateObject function. This can be used in VBScript and JScript scripts run in the WSH environment: WScript.CreateObject("WbemScripting.SWbemLocator") In ASP (Active Server Pages) there is supported the Server.CreateObject function in embedded script: Set Locator=Server.CreateObject("WbemScripting.SWbemLocator") In addition, the HTML <OBJECT> tag can be used with a PROGID attribute in the following manner: <OBJECT RUNAT=Server PROGID=Wbem.LocatorID=MyLocator></OBJECT> Client side script embedded in HTML supports the <OBJECT> tag with a CLASSID attribute: <OBJECT ID="MyLocator" CLASSID="CLSID:76A64158-CB41-11d1-8B02-00600806D9B6"></OBJECT> The SWbemServices and SWbemObject objects may also be Created from Moniker Display Names. This is supported in VB, VBScript and JScript by the GetObject call. By way of example of how monikers simplify scripts by putting multiple information in single string, the string Setobj=getobject"(winmgts:nspace/Disk=`c:`)" gets interpreted by the scripting API 74 as a sequence of instructions such as: Locator=NewActiveXObject ("Locator") Set Services=Locator.connector.services(nspace) Setobj=services.object("Disk=C:") From the moniker, the scripting API 74 knows that a services object is needed, and thus executes the above instructions to create a locator object. From the nspace parameter the API 74 knows to create a particular service object, and from the "Disk=C:" parameter knows to obtain the appropriate object from the services object. COLLECTIONS Considering next collections, certain WBEM object sets correspond to collections. As described above, a collection object is a type of Automation Object that provides built-in support for certain iterative constructs used by automation controllers. The following objects support Collection semantics:
Supports:
Collection Element Add Item Remove _NewEnum
Count
SWbemWbemNamedValueSet SWbemNamedValue .check mark. .check mark.
.check mark. .check mark. .check mark.
SWbemPropertySet SWbemProperty .check mark. .check mark.
.check mark. .check mark. .check mark.
SWbemQualifierSet SWbemQualifier .check mark. .check mark.
.check mark. .check mark. .check mark.
SWbemObjectSet SWbemObject x .check mark. x
.check mark. .check mark.
SWbemPrivilegeSet SWbemPrivilege .check mark. .check mark.
.check mark. .check mark. .check mark.
To support manipulation of collections via script, the native language features that surface collections are described in the following paragraphs. In VB and VBScript, the "for each . . . next" construction is used to manipulate collections, e.g.: for each Process in Getobject("winmgmts:").ExecQuery ("select Name from Win32_Process") WScript.Echo Process.Name next Alternatively, in Jscript, the Enumerator object is used to manipulate collections, e.g.: e=new Enumerator (myClass.Properties); for (;!e.atEnd( );e.moveNext ( )) { var y=e.item ( ); WScript.Echo (y.Name); } In Perl, the CPAN Win32 Standard Distribution supports the Enum object for creating collections, e.g.: use Win32::OLE; use Win32::OLE::Enum; foreach $inst (Win32::OLE::Enum.fwdarw.new(Win32::OLE.fwdarw.GetObject(`winmgmts: `).fwdarw.ExecQuery($ARGV[0])).fwdarw.All) { foreach $prop (Win32::OLE::Enum.fwdarw.new($inst.fwdarw.{Properties_}).fwdarw.All) { print "$prop.fwdarw.{Name} $prop.fwdarw.{Value}.backslash.n"; } } A collection includes a set of automation objects, and allows for iteration over the set in a standardized way that is understood by many scripting languages. OLE Automation defines a standard interface called "IEnumVARIANT" to provide a consistent, standardized mechanism for scripting languages to iterate over collections. Every OLE object that is to be a collection exposes a read-only property named "_NewEnum" that returns an enumerator object that supports "IEnumVARIANT". The presence of this property indicates to the scripting languages that the object is a collection and supports iteration. The IEnumVARIANT interface allows for the iteration of the objects contained within the collection, and includes "Next", "Reset", "Skip" and "Clone" methods. In addition to supporting the "NewEnum" property, collection objects also support a "Count" property that returns the number of items in the collection. Further, the collection object supports the "Item" method. Two further methods, "Add" and "Remove", can be optionally supported by collections. Several WMI scripting objects support collections, including "ISWbemObjectSet", "ISWbemNamedValueSet", "ISWbemQualifierSet", "ISWbemMethodSet", "ISWbemPropertySet" and "ISWbemPriviligeSet". When a scripting language supports COM automation, it is likely that it also includes some added support for "Automation Collections." The support provided by the scripting languages allows easy iteration of the elements in a collection without the need to resort to indexing systems. By way of example, consider the following piece of "Vbscript" script: for I=1 to processes.Count set process=processes.Item(I) Wscript.Echo process.name next I This script shows iteration through a set of process objects, wherein for each process object in the set, the name of the process is printed. Note that because this example does not use collections, a count variable is used to index the items in the collection. This makes the script relatively verbose, and also tends to convey that the set of objects is in some way ordered, which in general may not be true. The script below produces the same result, but uses standard collections to do the iteration: For each process in processes Wscript.Echo process.name Next process As should be apparent, this example script is less verbose and does not convey the notion of an ordered set. The combination of the support for collections within the WBEM Scripting API (in this example specifically "SWbemObjectSet"), and the explicit support for collections within the scripting languages, produce shorter and more intelligent script. Other scripting languages also contain varying degrees of support for collection objects. For example here is a "Jscript" script that uses collections to do the same thing as the script above: var e=new Enumerator(processes); for (;!e.atEnd( );e.moveNext( )) { var process=e.item ( ); WScript.Echo (process.Name); } From the above example, "JScript" provides support for collection objects by the use of a subsidiary object that is created to represent the object. In other words, with "Jscript," support for collections is not built into the language itself, but is instead added by the use of a subsidiary object. A clearer script is provided. The "perl" scripting language also uses a subsidiary object to represent collections, as set forth in the example below: foreach (in $processes) { print "$_.fwdarw.{name} "; } The WMI scripting objects that support collections are: "SWbemObjectSet", "SWbemNamedValueSet", "SWbemQualifierSet", "SWbemMethodSet", "SWbemPropertySet" and "SWbemPriviligeSet". The SWbemObjectSet collection represents a set of "SWbemObject" objects. The "Item" method used to access individual elements of the collection takes an object path (in the form of an "SWbemObjectPath") as a parameter. Items are not added or removed from this collection, so it does not support the optional "Add" and "Remove" methods. An example of the use of this collection is shown in the "VBScript" script fragment below, which prints out the name of each process in the process collection: For each process in processes Wscript.Echo process.name Next process The SWbemNamedValueSet collection represents a set of "SWbemNamedValue" objects. The "Item" method used to access individual elements of the collection takes a "name" parameter that is used to identify the specific "SWbemNamedValue" that needs to be accessed. Items in the collection can be added using the "Add" method and removed using the "Remove" method. This collection also exposes two extra methods. The "Clone" method allows a copy of the "SWbemNamedValueSet" collection to be made. The "DeleteAll" method provides an easy way of deleting all of the objects in the collection without the need to iterate and delete each one. An example of the use of this collection is shown in the "perl" script below: $keys=$process.fwdarw.{Path_}.fwdarw.{Keys}; foreach $key (in $keys) { print "Key: $key.fwdarw.{Name} Value: $key.fwdarw.{Value} .backslash.n"; } This script prints out the name and the value of each of the keys in the given "process" object. The "SWbemNamedValue" collection here is the "Keys_" property of the "SWemObjectPath" object. The SWbemQualifierSet collection represents a set of "SWbemQualifier" objects. The "Item" method used to access the individual elements of the collection takes a "name" parameter that is used to identify the specific "SWbemQualifer" that needs to be accessed. Items in the collection can be added using the "Add" method and removed using the "Remove" method. An example of the use of this collection is shown in the "JSript" script fragment below: Qualifiers.Add ("qsint32", 345); Qualifiers.Add ("qstring", "freddy the frog"); Qualifiers.Add ("qstring5", "wibble", true, true, false); Qualifiers("qsint32").Value=7677; WScript.Echo ("There are", Qualifiers.Count, "Qualifiers"); for (var e=new Enumerator (Qualifiers);!e.atEnd ( );e.moveNext ( )) { WScript.Echo (e.item ( ).Name, "=", e.item ( )); } This example shows several items ("SWbmQualifier objects) being added to the collection. The "Item" method is also used to illustrate the method of directly accessing a member of the collection. Finally the collection is iterated and some information is printed about each "SWbemQualifier" object. The SWbemMethodSet Object collection represents a set of "SWbemMethod" objects. The "Item" method uses to access the individual elements of the collection takes a "name" parameter that is used to identify the specific "SWbenMethod" that is to be accessed. Items cannot be added or removed from this collection, so the optional "Add" and "Remove" methods are not supported. An example of the use of this collection is shown in the "VBScript" script fragment below, which shows how information about the names of all of the methods in a class can be printed using an "SwbemMethodSet" object: Set service=GetObject("winmgmts:root/cimv2:win32_service") `Test the collection properties of IWbemMethodSet For each Method in service.Methods_WScript.Echo "METHOD:", Method.Name, "from class", Method. Origin Next The SWbemPropertySet Object collection represents a set of "SWbemProperty" objects. The "Item" method used to access the individual elements of the collection takes a "name" parameter that is used to identify the specific "SWbemProperty" that needs to be accessed. Items in the collection can be added using the "Add" method and removed using the "Remove" method. An example of the use of this collection is shown in the "VBScript" script fragment below: On Error Resume Next Set service=GetObject("winmgmts:root/cimv2:win32_service") `Test the collection properties of IWbemMethodSet For each Method in service.Methods_WScript.Echo "***************************" WScript.Echo "METHOD:", Method.Name, "from class", Method. Origin WScript.Echo WScript.Echo WScript.Echo "In Parameters:" if (Method.InParameters < > NULL) Then for each InParameter in Method.InParameters.Properties_WScript.Echo " ", InParameter.Name, "<", InParameter.CIMType, ">" Next End If WScript.Echo WScript.Echo "Out Parameters" if (Method.OutParameters < > NULL) Then for each OutParameter in Method.OutParameters.Properties_WScript.Echo " ", OutParameter.Name, "<", OutParameter.CIMType, ">" Next End If WScript.Echo WScript.Echo Next The above example shows how the "SWbemPropertySet" collection in conjunction with the "SWbemMethodSet" object may be used to print out the "in parameters" and the "out parameters" for the methods (represented by "SWbemMethod" objects) in a given class. The SWbemPrivilegeSet Object collection represents a set of "SWbemPrivilege" objects. The "Item" method used to access the individual elements of the collection takes a "WbemPrivilegeEnum" enumerator parameter that is used to identify the specific privilege to be accessed. Items in the collection can be added using the "Add" method and removed using the "Remove" method. ASYNCHRONOUS SCRIPTING As described above, synchronous operations requested of the API suspend until complete, which may include the returning of a result or an error. In accordance with another aspect of the present invention, there is provided an asynchronous behavior, in which operations requested of API return immediately, and then notify the calling script upon completion of the request (e.g., a result or an error). To this end, COM events, which implemented by using connection points, are used, which may be used in a variety of languages and environments. To implement COM events, when an object is created from a Windows Scripting Host (WSH) using the "Wscript.CreateObject ( )" method, an optional "strPrefix" can be specified. When this prefix string is specified, the WSH connects the object's outgoing interface to the script file after creating the object. When the object fires a COM style event, WSH calls a subroutine named strPrefix and the event name. By way of example, if the "strprefix" is "MYOBJ_" and the object fires an event named "OnGetObject", WSH calls the "MYOBJ_OnGetObject" subroutine located in the script. This same technique can be used when creating an object using a moniker using "Wscript.GetObject ( ) ". For example, Visual Basic programmers can declare variables that understand events by using the following syntax (introduced in VB 5.0): Dim WithEvents obj as ISWbemSink. This declaration allows the programmer to write event handlers using the "VariableName_EventName" convention. For example given the above definition, the programmer may write the following event handler: Sub obj_OnObjectReady(objObject, objAsyncObject, objAsyncContext) End Sub To implement COM and WMI Events in the scripting API 74, a number of steps are taken in order to expose the asynchronous behavior as COM events. More particularly, COM events are defined by including the "source" attribute on one or more interfaces in a coclass definition. The interfaces that define the events that can be fired by a coclass are called "source", or "outbound" interfaces. The "source" interfaces are interfaces that are implemented by an object in order that events may be received. In order to receive the results of asynchronous WBEM operations, some source interfaces are provided. In the case of the WBEM API for scripting, four events are defined, i.e., an event that indicates that a WBEM object has become available, an event that indicates that an operation has been completed, an event that gives indication of progress of an asynchronous call and an event that indicates that an object path is available (as the result of a "PutAsync_" call). The methods are contained within one source interface called "ISWbemSink." As set forth above, this interface is included as a "source" in the single coclass called "SWbemSink." There will be one other interface associated with this coclass called "ISWbemSinkControl." The ISWbemSinkControl interface contains the single method called "Cancel( )." An SWbemSink will either be created by the scriptwriter and passed in to the async call, or an SWbemSink will be created by the script API. In either case the object is returned by the async call. The IDL for "SWbemSink" coclass is set forth below: [ uuid(75718C9A-F029-11d1-A1AC-00C04FB6C223), helpstring("WBEM async sink") ] coclass SWbemSink { interface ISWbemSinkControl; [default, source] dispinterface ISWbemSink; }; Each of the methods or events within the "ISWbemSink" interface are also defined. Each of the methods defined in the interface have a logical name to make it clear what the event is signaling. Note that all of the outbound interfaces should be dispatch interfaces to allow maximum compatibility with scripting environments. The "ISWbemSink"" interface is set forth below: const ULONG WBEMS_DISPID_OBJECT_READY=1; const ULONG WBEMS_DISPID_COMPLETED=2; const ULONG WBEMS_DISPID_PROGRESS=3; const ULONG WBEMS_DISPID_OBJECT_PUT=4; [ uuid(75718CA0-F029-11d1-A1AC-00C04FB6C223), helpstring("Interface for WBEM Async result events") ] dispinterface ISWbemSink { properties: methods: [ id(WBEMS_DISPID_OBJECT_READY), helpstring("Async operation object available") ] void OnObjectReady( ISWbemObject *pObject, ISWbemNamedValueSet *objAsyncContext ); [ id(WBEMS_DISPID_COMPLETED), helpstring("Async operation completed") ] void OnCompleted ( WbemErrorEnum hResult, ISWbemObject *pErrorObject, ISWbemNamedValueSet *objAsyncContext ); [ id(WBEMS_DISPID_PROGRESS), helpstring("Async operation progress report") ] void OnProgress ( long upperBound, long current, BSTR message, ISWbemNamedValueSet *objAsyncContext ); [ id(WBEMS_DISPID_OBJECT_PUT), helpstring("Async operation object put path available") ] void OnObjectPut( ISWbemObjectPath *pObjectPath, ISWbemNamedValueSet *objAsyncContext ); }; In each case, the ISWbemNamedValueSet that was supplied to the original async call for the purposes of correlation is passed back. The "OnObjectReady" event will be fired whenever an object is ready to be processed. This may, for example, happen either when a single object is made available as the result of a call to "GetAsync ," or when one or more objects are available from the result of a query for example. When an asynchronous call is made that can result in more than one object being returned, the "OnObjectReady" method may be called repeatedly until all of the result objects have been made available. The "OnCompleted" handler is fired when an asynchronous call has been completed (this may be due to either success or failure). When "OnCompleted" is fired due to the successful completion of an asynchronous call, there may have been zero or more prior "OnObjectReady" calls. When an asynchronous call results in one or more objects being supplied via one or more calls to the "OnObjectReady" event, the "OnCompleted" event is guaranteed to be fired only after all of the related "OnObjectReady" events have returned. The "OnCompleted" event is passed an HRESULT, and an error object. The HRESULT is the final result returned from the async call. This may be an error, or a success code. In certain cases of error, an error object may be returned that gives further information about the error. The "OnProgress" event will be fired whenever progress is to be reported. The "OnProgress" event will be passed the upper bound of the progress, the current progress towards that upper bound, and a string that describes the current state of the progress. The "OnObjectPut" method will be called as the result of a call to PutAsync_( ). This event is fired prior to the "OnCompleted" event to provide the user with the object path of the object that was put. This can be very useful when the object that was "Put" did not yet have a key for example. In COM, "Connection Points" are used for registering and revoking callback interfaces with an object. An object provides an implementation of an "IConnectionPoint" interface for each type of interface that can be used for events. In general, Connection Points are not exposed as part of an object's identity, nor can they be discovered by the "QueryInterface". One IConnectionPoint interface is implemented in the WBEM API, and associated with the new SWbemSink coclass. The actual definition and implementation of the IconnectionPoint interface is described fully in many COM documents, and will not be discussed further here. Two important methods of the "IconnectionPoint" interface are "Advise ( ) " and "Unadvise ( ) ". These methods are used to register and un-register a sink with a connection point. To illustrate this, the following VB example is provided: Dim WithEvents tmpSink1 As SWbemSink Dim WithEvents tmpSink2 As SWbemSink Dim WithEvents tmpSink3 As SWbemSink Set tmpSinkl=New SWbemSink Set tmpSink2=tmpSink1 Set tmpSink3=tmpSink1 In this example, three sinks are added to a single connection using the "Advise( )" call. In this implementation, a large number of sinks can be registered to any one connection point. Unlike "Connection Points", "Connection Point Containers" are made visible to event sinks, and are the standard mechanism by which an even sink obtains an IconnectionPoint interface. Using an IconnectionPointContainer interface, an event sink can query all of the supported connection points or can obtain a specific connection point (referenced by a GUID). One IConnectionPointContainer interface is implemented in the WBEM API and supported by the SWbemSink coclass. Two more standard interfaces provide information at runtime about the events that an object supports. The two interfaces are "IprovideClassInfo", and "IprovideClassInfo2". These interfaces allow programmatic access to the type library 80 information via the "GetClassInfo( )" method. Again these interfaces are supported by the SWbemSink interface. A new asynchronous method is defined for each operation that can be performed asynchronously. These asynchronous versions of the methods are the same as the synchronous version, except that the method name includes the word "Async" after it, to distinguish it from the synchronous version. Also, the asynchronous version will take an extra parameter, which is an SWbemSink. Further, the asynchronous method will take an optional context in the form of an "ISWbemNamedValueSet" object The asynchronous form of the operations work when the user makes a call to an asynchronous operation by creating an SWbemSink object (using whatever mechanism is used in the scripting environment to create COM objects). The SWbemSink passed to the asynchronous call is used to receive the results of the async call in the form of events defined by the ISWbemSink "source" interface, and fired by the SWbemSink. Each scripting environment uses different techniques to bind the events defined by the SWbemSink returned and a particular subroutine in the scripting language. The ISWbemSinkControl can also be used to cancel the async operation via the "ISWbemSinkControl::Cancel ( )" method. If multiple operations are in progress using the same sink, then each of the outstanding operations will be cancelled. If the scriptwriter is in need of additional context information, it can be passed in the form of an "ISWbemNamedValueSet" object as an optional parameter to the call. As can be seen from the foregoing detailed description, there is provided a method and system that enable scripts to be used in a straightforward manner to access system management objects. The scripts are translated in a manner that is transparent to the scriptwriter, providing a flexible and extensible mechanism for accessing management information. While the invention is susceptible to various modifications and alternative constructions, certain illustrated embodiments thereof are shown in the drawings and have been described above in detail. It should be understood, however, that there is no intention to limit the invention to the specific form or forms disclosed, but on the contrary, the intention is to cover all modifications, alternative constructions, and equivalents falling within the spirit and scope of the invention.
|
Same subclass Same class Consider this |
||||||||||
