IFPCSystemPolicyRules2::RemoveVendorAccessSystemRule method

Applies to: desktop apps only

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

Syntax

HRESULT RemoveVendorAccessSystemRule(
  [in]  BSTR RuleGuid
);
FPCSystemPolicyRules.RemoveVendorAccessSystemRule( _
  ByVal RuleGuid As String _
)

Parameters

Return value

C++

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

VB

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

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.

Examples

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

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)

Version

Forefront Threat Management Gateway (TMG) 2010

IDL

Msfpccom.idl

DLL

Msfpccom.dll

See also

FPCSystemPolicyRules

 

 

Build date: 7/12/2010