Microsoft Identity Integration Server 2003 Developer Reference

Example: Preventing Connected Data Source Damage

The following Visual Basic Scripting Edition (VBScript) example shows how to prevent damage to the connector data source that can be caused by accidentally exporting too many object deletes. This example assumes that the Fabrikam AD MA management agent has an export step in the Full Export run profile. This example does not start the export profile if more then 50 objects are about to get deleted.

Option Explicit

On Error Resume Next

Const PktPrivacy = 6	 ' Authentication level

Dim ErrorLevel			 ' Return code

Dim Service				' Service object

Dim ManagementAgent		' Management agent

Dim ExportNumDeleteLimit   ' Export delete limit

Dim Status				 ' Status string

ErrorLevel = 1

Set Service = GetObject("winmgmts:{authenticationLevel=PktPrivacy}!root\MicrosoftIdentityIntegrationServer")

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

' This example limits export deletes to less than 50 objects.
ExportNumDeleteLimit = 50

' If the number of objects deletes to be exported is less than the specified limit,
' then export the objects. Do not export more than the specified limit.

If Clng(ManagementAgent.NumExportDelete) < Clng(ExportNumDeleteLimit) Then

   WScript.Echo "Exporting objects"

   Status = ManagementAgent.Execute("Export")

   If Status = "success" Then

	ErrorLevel = 0

	WScript.Echo "Export successful."

   Else

	WScript.Echo "Export failed with " & Status

   End If

Else

	WScript.Echo "Export Deletion Limit exceeded."

	WScript.Echo "You can only export " & ExportNumDeleteLimit & " object deletions."

	WScript.Echo "You are trying to export " & ManagementAgent.NumExportDelete & " object deletions."

End If

WScript.Quit(ErrorLevel)

Sub ErrorHandler (ErrorMessage)
  WScript.Echo ErrorMessage
  WScript.Quit(1)
End Sub

See Also

Preventing Damage to the Metaverse and Connected Data Source, Example: Preventing Metaverse Damage, Enabling Security in Scripts