Microsoft Internet Security and Acceleration Server 2000 |
The following portion of Visual Basic code adds a new site and content rule, called "Emergency_Site_Restriction", on the array level. The rule serves only one function, to limit access to a particular site; for example, www.sitetoblock.tld.
Dim objFPC As New FPCLib.FPC Dim array1 As FPCArray Dim rules As FPCSiteAndContentRules Dim rule As FPCSiteAndContentRule Dim destinationset As fpcDestinationSet 'Set the variable array1 equal to the array on which the script is being run Set array1 = objFPC.Arrays.GetContainingArray 'Get the destination sets collection Set DestinationSets = array1.PolicyElements.DestinationSets 'Add a destination set called "Emergency" Set destinationset = DestinationSets.Add("Emergency") 'Add a destination called "www.sitetoblock.tld" Set destination = destinationset.Add("www.sitetoblock.tld") 'Save the destination set destinationset.Save 'Get the Site and Content Rules collection Set rules = array1.ArrayPolicy.SiteAndContentRules 'Add a rule called "Emergency_Site_Restriction" Set rule = rules.Add("Emergency_Site_Restriction") 'Define the rule action to deny access rule.Action = fpcRuleActionDeny 'Define that the rule applies to all users, which is the default rule.AppliesToMethod = fpcAppliesToAll 'Define that the rule applies to all content, which is the default rule.AppliesToContentMethod = fpcAppliesToAllContent 'Define that the rule always applies rule.SetAppliesAlways 'Set the destination to which the rule applies rule.SetDestination fpcSpecifiedDestinationSet, "Emergency", fpcArrayScope 'Save the rule rule.Save
The VBScript derived from the preceding Visual Basic code is shown here. Note the setting of the enumerated types as constants, as described in Using Enumerated Types in Scripts.
const fpcRuleActionDeny = 1 const fpcAppliesToAll = 0 const fpcAppliesToAllContent = 0 const fpcSpecifiedDestinationSet = 3 const fpcArrayScope = 0 set isa = WScript.CreateObject("FPC.Root") Set array1 = isa.Arrays.GetContainingArray Set DestinationSets = array1.PolicyElements.DestinationSets Set destinationset = DestinationSets.Add("Emergency") Set destination = destinationset.Add("www.sitetoblock.tld") destinationset.Save Set rules = array1.ArrayPolicy.SiteAndContentRules Set rule = rules.Add("myrule") rule.Action = fpcRuleActionDeny rule.AppliesToMethod = fpcAppliesToAll rule.AppliesToContentMethod = fpcAppliesToAllContent rule.SetAppliesAlways rule.SetDestination fpcSpecifiedDestinationSet, "Emergency", fpcArrayScope rule.Save