Microsoft Identity Integration Server 2003 Developer Reference

Connecting to the WMI Service

To use the WMI provider, you must first connect to the WMI service on the server. By default, the current user credentials are used to connect to the service.

After connecting to the service, retrieve the object created by the WMI service. This object is based upon one of the classes in the WMI Provider.

This topic contains examples that illustrate how to connect to the WMI service.

Note  For clarity, the examples in this topic use the default Windows authentication settings for security. Consider the implication of using the default authentication settings before using these scripts in your environment. For more information, see Enabling Security in Scripts.

Connecting to a Local Server

The following Visual Basic Scripting Edition (VBScript) example shows how to connect to the WMI Service on a local server and retrieve the object based on the MIIS_ManagementAgent class. This example uses the current user credentials.

Option Explicit

Dim Service

Dim ManagementAgent

Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer")

Set ManagementAgent = Service.Get("MIIS_ManagementAgent.Name='Fabrikam HR MA'")

'* Start your script here.

Connecting to a Remote Server Using the Current User Credentials

The following VBScript example shows how to connect to a remote server using the current user credentials.

Option Explicit

Dim Locator

Dim Service

Dim ManagementAgent

Set Locator = CreateObject("WbemScripting.SWbemLocator")

Set Service = Locator.ConnectServer("MyServer", "root\MicrosoftIdentityIntegrationServer")

Set ManagementAgent = Service.Get("MIIS_ManagementAgent.Name='Fabrikam HR MA'")

'* Start your script here. 

Replace MyServer with the name of the remote server.

Connecting to a Remote Server Using Alternative Credentials

The following VBScript example shows how to connect to a remote server using alternative credentials.

Option Explicit

Dim Locator

Dim Service

Dim ManagementAgent

Set Service = Locator.ConnectServer("MyServer", "root\MicrosoftIdentityIntegrationServer", "Domain\Me", "MyPassword")

Set ManagementAgent = Service.Get("MIIS_ManagementAgent.Name='Fabrikam HR MA'")

'* Start your script here.

Replace the following:

Because this script contains a user name and password, store the script in a secure folder that has the same security level as the Microsoft Identity Integration Server 2003 folder. Limit access to this folder.

Note  We do not recommend storing user credentials in a script. If you need to run a script under a different user context, we recommend that you use the runas command to run the script. For more information, see Creating Scripts to Run Management Agents.

Important  Do not use this script to connect to a local server. If you specify the user name and password when you connect to a local server, the connection could fail. For more information, see the strUser parameter in the topic SWbemLocator.ConnectServer in the Windows Management Instrumentation SDK on the MSDN Web site.

Remarks

The Identity Manager can generate a VBScript script that can run a management agent with a specified run profile. For more information, see "Create a Script for a Management Agent Run Profile" in the Microsoft Identity Integration Server 2003 Help.

For more information about WMI, see the following topics in the Platform SDK: