RemoveVendorAccessSystemRule Method of the IFPCSystemPolicyRules2 Interface

The RemoveVendorAccessSystemRule method removes the FPCPolicyRule object representing the specified vendor-defined system policy rule from the collection.

C++

Syntax

HRESULT RemoveVendorAccessSystemRule(
  [in]  BSTR RuleGuid
);

Parameters

Return Value

This method returns S_OK if the call is successful; otherwise, it returns an error code.

Visual Basic

Syntax

Sub RemoveVendorAccessSystemRule( _
  ByVal RuleGuid As String _
)

Parameters

Return Value

This method has no return values. If the call is unsuccessful, an error is raised that can be intercepted by using an error handler.

Example Code

This VBScript script deletes the vendor-defined system policy rule with the name specified by the user.

Option Explicit
'Define the constants needed
Const Error_FileNotFound = &H80070002
Const Error_PredefinedRule = &HC0040335
Main(WScript.Arguments)
Sub Main(args)
    If(args.Count <> 1) Then
        Usage()
    End If
    DelVendorSystemPolicyRule args(0)
End Sub
Sub DelVendorSystemPolicyRule(RuleName)
    ' Create the root object and set the VendorMode property to True.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")
    root.VendorMode = True
    'Declare the other objects needed.
    Dim isaArray    ' An FPCArray object
    Dim spRules     ' An FPCSystemPolicyRules collection
    Dim spRule      ' An FPCPolicyRule object
    ' Get references to the array object and the system policy
    ' rules collection.
    Set isaArray = root.GetContainingArray()
    Set spRules = isaArray.SystemPolicy.PolicyRules
  
    On Error Resume Next
    Set spRule = spRules.Item(RuleName)
    If err.Number <> Error_FileNotFound Then
        Err.Clear
        spRules.RemoveVendorAccessSystemRule(spRule.PersistentName)
        If err.Number = Error_PredefinedRule Then
            WScript.Echo "The " & RuleName & " is a predefined system policy "_
                         & "rule and cannot be deleted."
        Else
            CheckError
            WScript.Echo "Deleting the system policy rule ..."
        End If
    Else
        WScript.Echo "The " & RuleName & " system policy rule was not found."
    End If
    On Error GoTo 0
    ' Save the changes to the new vendor system policy rule.
    spRules.Save
    root.VendorMode = False
    WScript.Echo "Done!"
End Sub 
Sub CheckError()
    If Err.Number <> 0 Then
        WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & ". " _
            & Err.Description
        Err.Clear
        root.VendorMode = False
        WScript.Quit
    End If
End Sub
Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  " & WScript.ScriptName & " RuleName" & VbCrLf _
        & "" & VbCrLf _
        & "  RuleName - Name of the vendor-defined system policy rule" 
    WScript.Quit
End Sub

Remarks

The GUID supplied in the RuleGuid parameter must be formatted as a string in the form {12345678-1234-1234-1234-123456789abc}. Note the presence of the braces normally used with GUIDs.

This method is available only when the VendorMode property of the FPC (root) object (IFPC2 interface in C++) is set to True (VARIANT_TRUE in C++).

System policy rules cannot be added or deleted in Forefront TMG Management.

Requirements

Client Requires Windows 7 or Windows Vista.
Server Requires Windows Server 2008 R2 or Windows Server 2008 x64 Edition with SP2.
Version Requires Forefront Threat Management Gateway (TMG) 2010.
IDL

Declared in Msfpccom.idl.

DLL

Requires Msfpccom.dll.

See Also

FPCSystemPolicyRules

Send comments about this topic to Microsoft

Build date: 6/30/2010