Copy the following code, and then paste it into Notepad./*
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This code is Copyright (c) 2005 Microsoft Corporation.
All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS BE
LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS CODE OR INFORMATION.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Title: AddMtuRule.js
Purpose: Adds an ICMP protocol definition and rule to all Enterprise Policies
Requirements:
- ISA 2004 Enterprise
- Access rights to ISA for interactive account
Run as: cscript addmturule.js protocolname networkname
Version:
1.0 06/15/2005 - First version
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
main();
function main()
{
var oISA = new ActiveXObject( "FPC.Root" );
var szCss = oISA.ConfigurationStorageServer;
oISA.ConnectToConfigurationStorageServer( szCss );
var oEnterprisePolicies = oISA.Enterprise.Policies;
var oEnterpriseRuleElements = oISA.Enterprise.RuleElements;
var ProtocolName = WScript.Arguments( 0 );
var EnterpriseNet = WScript.Arguments( 1 );
if( !MakeNewProtocol( oEnterpriseRuleElements, ProtocolName ) )
{
return false;
}
WScript.Echo( "Protocol Definition \'" + ProtocolName + "\' successfully created..." );
for( var inx = 1; inx <= oEnterprisePolicies.Count; inx++ )
{
switch( MakeNewRule( oEnterprisePolicies.Item( inx ), ProtocolName, EnterpriseNet ) )
{
case false: return false;
case 666: continue;
}
WScript.Echo( "....Access Rule \'" + ProtocolName + "\' successfully created..." );
}
WScript.Echo( "\r\nAll Done..." );
}
function MakeNewProtocol( oRuleElements, ProtocolName )
{
var Send = 1; //packet direction
var Code = 4; //ICMP code for Fragmentation needed
var Type = 3; //ICMP type for Destination unreachable
var oProtocol = null;
var Exists = -2147024713;
try
{
oProtocol = oRuleElements.ProtocolDefinitions.Add( ProtocolName );
}
catch( err )
{
if( err.number != Exists )
{
WScript.Echo( "Error " + err.number + "; " + err.description );
return false;
}
err.clear;
return true;
}
oProtocol.Description = "ICMP MTU Detection traffic";
oProtocol.PrimaryConnections.AddICMP( Send, Code, Type );
oProtocol.Save( );
return true;
}
function MakeNewRule( oPolicy, ProtocolName, EnterpriseNet )
{
var Allow = 0;
var SpecifiedProtocols = 1;
var EnterpriseScope = 1;
var IncludeStatus = 0;
var oRule = null;
WScript.Echo( "...working in policy \'" + oPolicy.Name + "\'..." );
if( oPolicy.Predefined )
{
WScript.Echo( "....Can\'t create rules in \'" + oPolicy.Name + "\'..." );
return 666; //can't do this here
}
try
{
oRule = oPolicy.PolicyRules.AddAccessRule( ProtocolName );
}
catch( err )
{
if( err.number != Exists )
{
WScript.Echo( "Error " + err.number + "; " + err.description );
return false;
}
err.clear;
return true;
}
oRule.Action = Allow;
oRule.Description = "ICMP MTU adjustment";
oRule.SourceSelectionIPs.EnterpriseNetworks.AddScopedItem( EnterpriseScope, EnterpriseNet, IncludeStatus );
oRule.AccessProperties.DestinationSelectionIPs.EnterpriseNetworks.AddScopedItem( EnterpriseScope, "Local Host", IncludeStatus );
oRule.AccessProperties.ProtocolSelectionMethod = SpecifiedProtocols;
oRule.AccessProperties.SpecifiedProtocols.AddScopedItem( EnterpriseScope, ProtocolName, IncludeStatus );
oRule.AccessProperties.UserSets.AddScopedItem( EnterpriseScope, "All Users", IncludeStatus );
oRule.Save( true );
return true;
}
|