Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C:\Users\xxx\Documents\cs_code\MSFT_NetFirewallRule.cs [11/27/2016 5:58:07 AM] ./
- using Hydra.Types;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Diagnostics;
- using System.Management;
- using System.Text;
- namespace Hydra.Objects
- {
- //|=-=<OO>=-==-=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=-|
- //| |
- //| This C# and MSSQL Code was generated by -=<( HydraCodeGen, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null )>=- |
- //| |
- //| Version 2.0.0.0on 11-27-2016 05:58:06.998 |
- //| |
- //| Code Generation Complete! (4,411.00) lines of code generated in 468.78 milliseconds. |
- //| |
- //|=-=<OO>=-==-=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=----=<OO>=-|
- ///<summary>
- /// Represents a Windows firewall rule.
- ///</summary>
- public partial class MSFT_NetFirewallRule
- {
- #region (Constructor) public MSFT_NetFirewallRule() {}
- /// <summary>
- /// Default constructor
- /// </summary>
- public MSFT_NetFirewallRule( )
- {
- _load_Key_Properties();
- }
- #endregion
- #region (constructor) public MSFT_NetFirewallRule(string hostname, string namespace, bool preload)
- /// <summary>
- /// Creates an instance of the (MSFT_NetFirewallRule) class and
- /// collects all instances immediately
- /// </summary>
- /// <param name-"preload">Set to true if you want the wmi data loaded immediately</param>
- public MSFT_NetFirewallRule( bool preload, string p_hostname, string p_namespace, string p_wmiquery )
- {
- _load_Key_Properties();
- this.HostName = p_hostname;
- this.NameSpace = p_namespace;
- this._wmiquery = p_wmiquery;
- if (preload)
- {
- this.ALLInstances = Get_All_MSFT_NetFirewallRule_Objects();
- }
- }
- #endregion
- #region (constructor) public MSFT_NetFirewallRule(string p_hostname, string p_username, string p_password, long p_KnownHostID )
- /// <summary>
- /// Creates an instance of the MSFT_NetFirewallRule class, connects to wmi, scans the object(s) and stores the data in the database (otional)
- /// </summary>
- /// <param name="p_host">Hostname to scan. if "" or null localhoist is assumed</param>
- /// <param name="p_user">Username to scan with. only used on remote connections</param>
- /// <param name="p_pas">password to scan with. only used on remote connections</param>
- /// <param name="customquery">Custom wmi query to use (if so desired) if null or "" then SELECT * FROM [CLASSNAME] is assumed</param>
- /// <param name="pKHID">Known Host ID from the ___HydraKnownHost table</param>
- /// <param name="p_isLocal">set to true for local connections</param>
- /// <param name="p_UpdateDB">Update the database with all instances returned</param>
- /// <param name="deleteoldrecordsfirst">Delete all instances of classname before uploading all new instances (disable this for perf classes)</param>
- public MSFT_NetFirewallRule(string p_host, string p_user, string p_pas, string customquery, long pKHID, bool p_isLocal, bool p_UpdateDB, bool deleteoldrecordsfirst)
- {
- try
- {
- this._knownhostid = pKHID;
- this._hostname = p_host;
- if (!p_isLocal)
- {
- this._hostname = p_host;
- this._username = p_user;
- this._password = p_pas;
- this._islocalconnection = p_isLocal;
- }
- if (customquery != null)
- {
- if (customquery != "" )
- {
- this._wmiquery = customquery;
- }
- }
- int instanceindex = 0;
- this.ALLInstances = Get_All_MSFT_NetFirewallRule_Objects();
- if (p_UpdateDB)
- {
- foreach (MSFT_NetFirewallRule o in this.ALLInstances)
- {
- if(instanceindex == 0 && deleteoldrecordsfirst)
- {
- MSFT_NetFirewallRule_DELETE_BY_KNOWN_HOST_ID(pKHID, Config.DBCONN_HYDRA_DB);
- }
- o._hostname = this._hostname;
- o._username = this._username;
- o._password = this._password;
- o.InsertIntoDatabase(Config.DBCONN_HYDRA_DB);
- instanceindex++;
- System.Threading.Thread.Sleep(3); //rest
- }
- }
- else
- {
- Logging.LogEventlogException(new ApplicationException("HydraB is Offline!!!!"),"MSFT_NetFirewallRule", 911);
- }
- }
- catch(Exception xxl)
- {
- Logging.LogEventlogException(xxl, "MSFT_NetFirewallRule", 911);
- }
- }
- #endregion
- #region Properties
- #region Property: Key Properties
- /// <summary>
- /// ArrayList to hold property names that uniquely identify the instances in the collection
- /// </summary>
- private ArrayList _key_properties = new ArrayList();
- public ArrayList KeyProperties
- {
- get
- {
- return _key_properties;
- }
- set
- {
- _key_properties = value;
- }
- }
- #endregion
- #region Property: ALLInstances
- /// <summary>
- /// ArrayList to hold objects
- /// </summary>
- private ArrayList _ALLinstances;
- public ArrayList ALLInstances
- {
- get
- {
- return _ALLinstances;
- }
- set
- {
- _ALLinstances = value;
- }
- }
- #endregion Property: ALLInstances
- #region Property: List<Property_Data> Properties
- /// <summary>
- /// Holds the collective properties of this class or instance
- ///
- /// </summary>
- private List<Property_Data> _properties = new List<Property_Data>();
- /// <summary>
- /// Holds the collective properties of this class or instance
- ///
- /// </summary>
- public List<Property_Data> Properties
- {
- get
- {
- return _properties;
- }
- set
- {
- _properties = value;
- }
- }
- #endregion Property: List<Property_Data>
- #region Property: ISLocalConnection
- /// <summary>
- /// KnownHostID is the value that uniquely identifies a host in the hydra database
- /// </summary>
- private bool _islocalconnection = true;
- public bool ISLocalConnection
- {
- get
- {
- return _islocalconnection;
- }
- set
- {
- _islocalconnection = value;
- }
- }
- #endregion Property: HydraID
- #region Property: KnownHostID
- /// <summary>
- /// KnownHostID is the value that uniquely identifies a host in the hydra database
- /// </summary>
- private Int64 _knownhostid = -9;
- public Int64 KnownHostID
- {
- get
- {
- return _knownhostid;
- }
- set
- {
- _knownhostid = value;
- }
- }
- #endregion Property: HydraID
- #region Property: HydraID
- /// <summary>
- /// HydraID is a value that is created in the sql database when you add a record to a table
- /// it is extremely helpful when trying to create relationships between tables in the database server
- /// </summary>
- private Int64 _hydraid;
- public Int64 HydraID
- {
- get
- {
- return _hydraid;
- }
- set
- {
- _hydraid = value;
- }
- }
- #endregion Property: HydraID
- #region Property: WMIQuery
- /// <summary>
- /// The WMI Query that was run against the WMI Provider
- /// Example: "SELECT * FROM WIN32_PROCESS"
- /// </summary>
- private string _wmiquery = "SELECT * FROM MSFT_NetFirewallRule";
- public string WMIQuery
- {
- get
- {
- return _wmiquery;
- }
- set
- {
- _wmiquery = value;
- }
- }
- #endregion Property: WMIQuery
- #region Property: HostName
- /// <summary>
- /// Hostname is the host you want to run the query against.
- /// Example: dns_server.mycompany.com or 10.10.220.18
- /// </summary>
- private string _hostname = Environment.MachineName;
- public string HostName
- {
- get
- {
- return _hostname;
- }
- set
- {
- _hostname = value;
- }
- }
- #endregion Property: HostName
- #region Property: UserName
- /// <summary>
- /// UserName is the username you want to use to run the query
- /// </summary>
- private string _username = "";
- public string UserName
- {
- get
- {
- return _username;
- }
- set
- {
- _username = value;
- }
- }
- #endregion
- #region Property: Password
- /// <summary>
- /// password to use when connecting to remote hosts
- /// leave blank to use integrated security
- /// </summary>
- private string _password = "";
- public string Password
- {
- get
- {
- return _password;
- }
- set
- {
- _password = value;
- }
- }
- #endregion
- #region Property: NameSpace
- /// <summary>
- /// WMI Namespace
- /// </summary>
- private string _namespace = "ROOT\\StandardCimv2";
- public string NameSpace
- {
- get
- {
- return _namespace;
- }
- set
- {
- _namespace = value;
- }
- }
- #endregion Property: NameSpace
- #region Property: WMICLASS
- /// <summary>
- /// WMICLASS
- /// </summary>
- private string _wmiclass = "MSFT_NetFirewallRule";
- public string WMIClass
- {
- get
- {
- return _wmiclass;
- }
- set
- {
- _wmiclass = value;
- }
- }
- #endregion Property: WMICLASS
- #region Property: RelPath
- /// <summary>
- /// Relative Path
- /// </summary>
- private string _relpath = "MSFT_NetFirewallRule";
- public string RelPath
- {
- get
- {
- return _relpath;
- }
- set
- {
- _relpath = value;
- }
- }
- #endregion Property: NameSpace
- #region Property: InstancePath
- /// <summary>
- /// This.InstancePath
- /// </summary>
- private string _instancepath = "";
- public string InstancePath
- {
- get
- {
- return _instancepath;
- }
- set
- {
- _instancepath = value;
- }
- }
- #endregion Property: NameSpace
- #region Property: DatabaseConnectionString
- /// <summary>
- /// this field holds the DatabaseConnectionString for saving WMI Data to a mssql database
- /// </summary>
- private string _databaseconnectionstring;
- public string DatabaseConnectionString
- {
- get
- {
- return _databaseconnectionstring;
- }
- set
- {
- _databaseconnectionstring = value;
- }
- }
- #endregion Property: DatabaseConnectionString
- #region Property: Action
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Action" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | No | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Specifies the action to take on traffic that matches this rule.
- /// </summary>
- public ushort varAction
- {
- set
- {
- _varaction = value;
- }
- get
- {
- return _varaction;
- }
- }
- private ushort _varaction = new ushort();
- #endregion Property: varAction
- #region Property: Caption
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Caption" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | Yes | Yes | No | 5 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The Caption property is a short textual description (one- line string) of the object.
- /// </summary>
- public string varCaption
- {
- set
- {
- _varcaption = value;
- }
- get
- {
- return _varcaption;
- }
- }
- private string _varcaption = "";
- public bool CaptionIsReadable = true;
- public double CaptionMaxLength = 64;
- #endregion Property: varCaption
- #region Property: CommonName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "CommonName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public string varCommonName
- {
- set
- {
- _varcommonname = value;
- }
- get
- {
- return _varcommonname;
- }
- }
- private string _varcommonname = "";
- public bool CommonNameIsReadable = true;
- #endregion Property: varCommonName
- #region Property: ConditionListType
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "ConditionListType" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | Yes | No | No | No | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public ushort varConditionListType
- {
- set
- {
- _varconditionlisttype = value;
- }
- get
- {
- return _varconditionlisttype;
- }
- }
- private ushort _varconditionlisttype = new ushort();
- public bool ConditionListTypeIsReadable = true;
- #endregion Property: varConditionListType
- #region Property: CreationClassName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "CreationClassName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Yes | No | No | No | Yes | No | No | Yes | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Reserved for internal use by the WMI provider only.
- /// </summary>
- public string varCreationClassName
- {
- set
- {
- _varcreationclassname = value;
- }
- get
- {
- return _varcreationclassname;
- }
- }
- private string _varcreationclassname = "";
- public bool CreationClassNameIsReadable = true;
- public double CreationClassNameMaxLength = 256;
- #endregion Property: varCreationClassName
- #region Property: Description
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Description" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 3 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// A brief description of the rule. May be an indirect string. If it is an indirect string,
- /// then it may not be overwritten.
- /// </summary>
- public string varDescription
- {
- set
- {
- _vardescription = value;
- }
- get
- {
- return _vardescription;
- }
- }
- private string _vardescription = "";
- #endregion Property: varDescription
- #region Property: Direction
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Direction" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | No | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Specifies which direction of traffic to match with this rule.
- /// </summary>
- public ushort varDirection
- {
- set
- {
- _vardirection = value;
- }
- get
- {
- return _vardirection;
- }
- }
- private ushort _vardirection = new ushort();
- #endregion Property: varDirection
- #region Property: DisplayGroup
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "DisplayGroup" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 3 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The group that this rule belongs to. This field is based on the value of RuleGroup and changes
- /// to this field are ignored.
- /// </summary>
- public string varDisplayGroup
- {
- set
- {
- _vardisplaygroup = value;
- }
- get
- {
- return _vardisplaygroup;
- }
- }
- private string _vardisplaygroup = "";
- public bool DisplayGroupIsReadable = true;
- #endregion Property: varDisplayGroup
- #region Property: DisplayName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "DisplayName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 3 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The localized name of this rule. This field's value is based on the value of ElementName.
- /// Changes to this field are ignored.
- /// </summary>
- public string varDisplayName
- {
- set
- {
- _vardisplayname = value;
- }
- get
- {
- return _vardisplayname;
- }
- }
- private string _vardisplayname = "";
- public bool DisplayNameIsReadable = true;
- #endregion Property: varDisplayName
- #region Property: EdgeTraversalPolicy
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "EdgeTraversalPolicy" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | No | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Specifies how this firewall rule will handle edge traversal cases.
- /// </summary>
- public ushort varEdgeTraversalPolicy
- {
- set
- {
- _varedgetraversalpolicy = value;
- }
- get
- {
- return _varedgetraversalpolicy;
- }
- }
- private ushort _varedgetraversalpolicy = new ushort();
- #endregion Property: varEdgeTraversalPolicy
- #region Property: ElementName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "ElementName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 3 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The locale-independent name of the rule. May be an indirect string.
- /// </summary>
- public string varElementName
- {
- set
- {
- _varelementname = value;
- }
- get
- {
- return _varelementname;
- }
- }
- private string _varelementname = "";
- #endregion Property: varElementName
- #region Property: Enabled
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Enabled" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | Yes | No | No | No | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Indicates whether this rule is administratively enabled or disabled.
- /// </summary>
- public ushort varEnabled
- {
- set
- {
- _varenabled = value;
- }
- get
- {
- return _varenabled;
- }
- }
- private ushort _varenabled = new ushort();
- public bool EnabledIsReadable = true;
- #endregion Property: varEnabled
- #region Property: EnforcementStatus
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "EnforcementStatus" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | Yes | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// If this object is retrieved from the ActiveStore, describes the current enforcement status
- /// of the rule.
- /// </summary>
- public ushort[] varEnforcementStatus
- {
- set
- {
- _varenforcementstatus = value;
- }
- get
- {
- return _varenforcementstatus;
- }
- }
- private ushort[] _varenforcementstatus = new ushort[1];
- #endregion Property: varEnforcementStatus
- #region Property: ExecutionStrategy
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "ExecutionStrategy" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | Yes | No | No | No | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public ushort varExecutionStrategy
- {
- set
- {
- _varexecutionstrategy = value;
- }
- get
- {
- return _varexecutionstrategy;
- }
- }
- private ushort _varexecutionstrategy = new ushort();
- public bool ExecutionStrategyIsReadable = true;
- #endregion Property: varExecutionStrategy
- #region Property: InstanceID
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "InstanceID" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// A string that uniquely identifies this instance within the PolicyStore.
- /// </summary>
- public string varInstanceID
- {
- set
- {
- _varinstanceid = value;
- }
- get
- {
- return _varinstanceid;
- }
- }
- private string _varinstanceid = "";
- public bool InstanceIDIsReadable = true;
- #endregion Property: varInstanceID
- #region Property: LocalOnlyMapping
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "LocalOnlyMapping" CimType:Boolean )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Whether to group UDP packets into conversations based only upon the local address and port.
- /// Applies only to UDP.
- /// </summary>
- public bool varLocalOnlyMapping
- {
- set
- {
- _varlocalonlymapping = value;
- }
- get
- {
- return _varlocalonlymapping;
- }
- }
- private bool _varlocalonlymapping = new bool();
- #endregion Property: varLocalOnlyMapping
- #region Property: LooseSourceMapping
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "LooseSourceMapping" CimType:Boolean )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Whether to group UDP packets into conversations based upon the local address, local port, and
- /// remote port. Applies only to UDP.
- /// </summary>
- public bool varLooseSourceMapping
- {
- set
- {
- _varloosesourcemapping = value;
- }
- get
- {
- return _varloosesourcemapping;
- }
- }
- private bool _varloosesourcemapping = new bool();
- #endregion Property: varLooseSourceMapping
- #region Property: Mandatory
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Mandatory" CimType:Boolean )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public bool varMandatory
- {
- set
- {
- _varmandatory = value;
- }
- get
- {
- return _varmandatory;
- }
- }
- private bool _varmandatory = new bool();
- public bool MandatoryIsReadable = true;
- #endregion Property: varMandatory
- #region Property: Owner
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Owner" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The owner of the firewall rule, as a SID.
- /// </summary>
- public string varOwner
- {
- set
- {
- _varowner = value;
- }
- get
- {
- return _varowner;
- }
- }
- private string _varowner = "";
- #endregion Property: varOwner
- #region Property: Platforms
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Platforms" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | Yes | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Specifies which platforms the rule is applicable on. If null, the rule applies to all platforms
- /// (the default). Each entry takes the form Major.Minor+, for instance 6.0, 6.1+, or 6.2. If
- /// + is specified, then it means that the rule applies to that version or greater. For instance,
- /// Windows Vista could be represented as 6 or 6.0, and Windows 7 or later would be represented
- /// as 6.1+. + may only be attached to the final item in the list. 6.0+ is not valid because
- /// it means the same thing as null (all platforms).
- /// </summary>
- public string[] varPlatforms
- {
- set
- {
- _varplatforms = value;
- }
- get
- {
- return _varplatforms;
- }
- }
- private string[] _varplatforms = new string[1];
- #endregion Property: varPlatforms
- #region Property: PolicyDecisionStrategy
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyDecisionStrategy" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | Yes | No | No | No | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public ushort varPolicyDecisionStrategy
- {
- set
- {
- _varpolicydecisionstrategy = value;
- }
- get
- {
- return _varpolicydecisionstrategy;
- }
- }
- private ushort _varpolicydecisionstrategy = new ushort();
- public bool PolicyDecisionStrategyIsReadable = true;
- #endregion Property: varPolicyDecisionStrategy
- #region Property: PolicyKeywords
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyKeywords" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | Yes | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public string[] varPolicyKeywords
- {
- set
- {
- _varpolicykeywords = value;
- }
- get
- {
- return _varpolicykeywords;
- }
- }
- private string[] _varpolicykeywords = new string[1];
- public bool PolicyKeywordsIsReadable = true;
- #endregion Property: varPolicyKeywords
- #region Property: PolicyRoles
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyRoles" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | Yes | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public string[] varPolicyRoles
- {
- set
- {
- _varpolicyroles = value;
- }
- get
- {
- return _varpolicyroles;
- }
- }
- private string[] _varpolicyroles = new string[1];
- public bool PolicyRolesIsReadable = true;
- #endregion Property: varPolicyRoles
- #region Property: PolicyRuleName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyRuleName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Yes | No | No | No | Yes | No | No | Yes | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Reserved for internal use by the WMI provider only.
- /// </summary>
- public string varPolicyRuleName
- {
- set
- {
- _varpolicyrulename = value;
- }
- get
- {
- return _varpolicyrulename;
- }
- }
- private string _varpolicyrulename = "";
- public bool PolicyRuleNameIsReadable = true;
- public double PolicyRuleNameMaxLength = 256;
- #endregion Property: varPolicyRuleName
- #region Property: PolicyStoreSource
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyStoreSource" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// If this object is retrieved from the ActiveStore, with the TracePolicyStoreSource option set,
- /// contains the path to the PolicyStore where this rule originally came from.
- /// </summary>
- public string varPolicyStoreSource
- {
- set
- {
- _varpolicystoresource = value;
- }
- get
- {
- return _varpolicystoresource;
- }
- }
- private string _varpolicystoresource = "";
- #endregion Property: varPolicyStoreSource
- #region Property: PolicyStoreSourceType
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PolicyStoreSourceType" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// If this object is retrieved from the ActiveStore, with the TracePolicyStoreSource option set,
- /// describes the type of PolicyStore where this rule originally came from.
- /// </summary>
- public ushort varPolicyStoreSourceType
- {
- set
- {
- _varpolicystoresourcetype = value;
- }
- get
- {
- return _varpolicystoresourcetype;
- }
- }
- private ushort _varpolicystoresourcetype = new ushort();
- #endregion Property: varPolicyStoreSourceType
- #region Property: PrimaryStatus
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "PrimaryStatus" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | No | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// PrimaryStatus provides a high level status value, intended to align with Red-Yellow-Green type
- /// representation of status. It should be used in conjunction with DetailedStatus to provide high
- /// level and detailed health status of the ManagedElement and its subcomponents. PrimaryStatus
- /// consists of one of the following values: Unknown, OK, Degraded or Error. "Unknown" indicates
- /// the implementation is in general capable of returning this property, but is unable to do so
- /// at this time. "OK" indicates the ManagedElement is functioning normally. "Degraded" indicates
- /// the ManagedElement is functioning below normal. "Error" indicates the ManagedElement is in
- /// an Error condition.
- /// </summary>
- public ushort varPrimaryStatus
- {
- set
- {
- _varprimarystatus = value;
- }
- get
- {
- return _varprimarystatus;
- }
- }
- private ushort _varprimarystatus = new ushort();
- #endregion Property: varPrimaryStatus
- #region Property: Priority
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Priority" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public ushort varPriority
- {
- set
- {
- _varpriority = value;
- }
- get
- {
- return _varpriority;
- }
- }
- private ushort _varpriority = new ushort();
- public bool PriorityIsReadable = true;
- #endregion Property: varPriority
- #region Property: Profiles
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Profiles" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | No | No | No | No | Yes | No | 4 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Which profiles this rule is active on.
- /// </summary>
- public ushort varProfiles
- {
- set
- {
- _varprofiles = value;
- }
- get
- {
- return _varprofiles;
- }
- }
- private ushort _varprofiles = new ushort();
- #endregion Property: varProfiles
- #region Property: RuleGroup
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "RuleGroup" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The locale-independent name for the group that this rule belongs to. If this field is non-null,
- /// then Windows Firewall with Advanced Security assumes that this rule belongs to a Windows component
- /// or an installed application, and some parts of the rule are protected (including but not limited
- /// to the Name, Description, Program, and Service).
- /// </summary>
- public string varRuleGroup
- {
- set
- {
- _varrulegroup = value;
- }
- get
- {
- return _varrulegroup;
- }
- }
- private string _varrulegroup = "";
- #endregion Property: varRuleGroup
- #region Property: RuleUsage
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "RuleUsage" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | Yes | No | No | No | Yes | No | 4 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public string varRuleUsage
- {
- set
- {
- _varruleusage = value;
- }
- get
- {
- return _varruleusage;
- }
- }
- private string _varruleusage = "";
- public bool RuleUsageIsReadable = true;
- #endregion Property: varRuleUsage
- #region Property: SequencedActions
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "SequencedActions" CimType:UInt16 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | Yes | Yes | Yes | No | No | No | Yes | No | 6 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// This field is ignored.
- /// </summary>
- public ushort varSequencedActions
- {
- set
- {
- _varsequencedactions = value;
- }
- get
- {
- return _varsequencedactions;
- }
- }
- private ushort _varsequencedactions = new ushort();
- public bool SequencedActionsIsReadable = true;
- #endregion Property: varSequencedActions
- #region Property: Status
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "Status" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The detailed status of the rule, as a string.
- /// </summary>
- public string varStatus
- {
- set
- {
- _varstatus = value;
- }
- get
- {
- return _varstatus;
- }
- }
- private string _varstatus = "";
- #endregion Property: varStatus
- #region Property: StatusCode
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "StatusCode" CimType:UInt32 )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| No | No | No | No | No | No | No | No | Yes | No | 2 | Yes |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// The detailed status of the rule, as a numeric error code.
- /// </summary>
- public uint varStatusCode
- {
- set
- {
- _varstatuscode = value;
- }
- get
- {
- return _varstatuscode;
- }
- }
- private uint _varstatuscode = new uint();
- #endregion Property: varStatusCode
- #region Property: SystemCreationClassName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "SystemCreationClassName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Yes | No | No | No | Yes | No | No | Yes | Yes | No | 7 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Reserved for internal use by the WMI provider only.
- /// </summary>
- public string varSystemCreationClassName
- {
- set
- {
- _varsystemcreationclassname = value;
- }
- get
- {
- return _varsystemcreationclassname;
- }
- }
- private string _varsystemcreationclassname = "";
- public bool SystemCreationClassNameIsReadable = true;
- public double SystemCreationClassNameMaxLength = 256;
- #endregion Property: varSystemCreationClassName
- #region Property: SystemName
- ///|----------------------------------------------------------------------------------------------------|
- ///| |
- ///| -=( Property: "SystemName" CimType:String )=- |
- ///| |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Key | CIMKEY | Values | ValueMap | Read | Write | Units | MaxLen | Desc | Array | Quals | Local |
- ///|----------------------------------------------------------------------------------------------------|
- ///| Yes | No | No | No | Yes | No | No | Yes | Yes | No | 7 | No |
- ///|----------------------------------------------------------------------------------------------------|
- /// <summary>
- /// Reserved for internal use by the WMI provider only.
- /// </summary>
- public string varSystemName
- {
- set
- {
- _varsystemname = value;
- }
- get
- {
- return _varsystemname;
- }
- }
- private string _varsystemname = "";
- public bool SystemNameIsReadable = true;
- public double SystemNameMaxLength = 256;
- #endregion Property: varSystemName
- #region Load Key Properties
- private void _load_Key_Properties()
- {
- /// varCreationClassName is a Key Property
- _key_properties.Add("varCreationClassName");
- /// varPolicyRuleName is a Key Property
- _key_properties.Add("varPolicyRuleName");
- /// varSystemCreationClassName is a Key Property
- _key_properties.Add("varSystemCreationClassName");
- /// varSystemName is a Key Property
- _key_properties.Add("varSystemName");
- }
- #endregion
- #endregion
- #region public int Execute_Enable_Method()
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public int Execute_Enable_Method()
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///<summary>
- /// Execute_Enable_Method()
- ///</summary>
- ///<returns>int ReturnValue</returns>
- public int Execute_Enable_Method( string instancepath )
- {
- int i = -1;
- try{
- string ip = instancepath;
- if (this.InstancePath != "") { ip = this.InstancePath; }
- else { ip = "MSFT_NetFirewallRule=@"; }
- ManagementScope scope = new ManagementScope("ROOT\\StandardCimv2");
- ManagementObject mo = new ManagementObject(scope, new ManagementPath(ip), new ObjectGetOptions());
- mo.Scope.Options.EnablePrivileges = true;
- ManagementBaseObject param = mo.InvokeMethod( "Enable" , null , null );
- i = Convert.ToInt32(param[ "ReturnValue" ].ToString());
- mo.Dispose();
- } catch (Exception ex) { LogError(ex); }
- return i;
- }
- #endregion public int Execute_Enable_Method()
- #region public int Execute_Disable_Method()
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public int Execute_Disable_Method()
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///<summary>
- /// Execute_Disable_Method()
- ///</summary>
- ///<returns>int ReturnValue</returns>
- public int Execute_Disable_Method( string instancepath )
- {
- int i = -1;
- try{
- string ip = instancepath;
- if (this.InstancePath != "") { ip = this.InstancePath; }
- else { ip = "MSFT_NetFirewallRule=@"; }
- ManagementScope scope = new ManagementScope("ROOT\\StandardCimv2");
- ManagementObject mo = new ManagementObject(scope, new ManagementPath(ip), new ObjectGetOptions());
- mo.Scope.Options.EnablePrivileges = true;
- ManagementBaseObject param = mo.InvokeMethod( "Disable" , null , null );
- i = Convert.ToInt32(param[ "ReturnValue" ].ToString());
- mo.Dispose();
- } catch (Exception ex) { LogError(ex); }
- return i;
- }
- #endregion public int Execute_Disable_Method()
- #region public int Execute_Rename_Method()
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// Execute_Rename_Method(string instancepath, String _newname )
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///<summary>
- /// Execute_Rename_Method( string instancepath, String _newname )
- ///</summary>
- ///<returns>int ReturnValue</returns>
- public int Execute_Rename_Method( string instancepath, String _newname )
- {
- int i = -1;
- try {
- string ip = instancepath;
- if (this.InstancePath != "") { ip = this.InstancePath; }
- else { ip = "=@"; }
- ManagementScope scope = new ManagementScope("ROOT\\StandardCimv2");
- ManagementObject mo = new ManagementObject(scope, new ManagementPath(ip), new ObjectGetOptions());
- mo.Scope.Options.EnablePrivileges = true;
- mo.Scope.Connect();
- ManagementBaseObject inparams = mo.GetMethodParameters( "Rename" );
- inparams["NewName"] = (String)_newname;
- ManagementBaseObject param = mo.InvokeMethod( "Rename" , inparams , null );
- i = Convert.ToInt32(param[ "ReturnValue" ].ToString());
- mo.Dispose();
- } catch (Exception ex) { LogError(ex); }
- return i;
- }
- #endregion public int Execute_Rename_Method()
- #region public int Execute_CloneObject_Method()
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// Execute_CloneObject_Method(string instancepath, String _newgposession, String _newname, String _newpolicystore
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///<summary>
- /// Execute_CloneObject_Method( string instancepath, String _newgposession, String _newname, String _newpolicystore )
- ///</summary>
- ///<returns>int ReturnValue</returns>
- public int Execute_CloneObject_Method( string instancepath, String _newgposession, String _newname, String _newpolicystore )
- {
- int i = -1;
- try {
- string ip = instancepath;
- if (this.InstancePath != "") { ip = this.InstancePath; }
- else { ip = "=@"; }
- ManagementScope scope = new ManagementScope("ROOT\\StandardCimv2");
- ManagementObject mo = new ManagementObject(scope, new ManagementPath(ip), new ObjectGetOptions());
- mo.Scope.Options.EnablePrivileges = true;
- mo.Scope.Connect();
- ManagementBaseObject inparams = mo.GetMethodParameters( "CloneObject" );
- inparams["NewGPOSession"] = (String)_newgposession;
- inparams["NewName"] = (String)_newname;
- inparams["NewPolicyStore"] = (String)_newpolicystore;
- ManagementBaseObject param = mo.InvokeMethod( "CloneObject" , inparams , null );
- i = Convert.ToInt32(param[ "ReturnValue" ].ToString());
- mo.Dispose();
- } catch (Exception ex) { LogError(ex); }
- return i;
- }
- #endregion public int Execute_CloneObject_Method()
- #region public int Execute_EnumerateFull_Method()
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public int Execute_EnumerateFull_Method()
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///<summary>
- /// Execute_EnumerateFull_Method()
- ///</summary>
- ///<returns>int ReturnValue</returns>
- public int Execute_EnumerateFull_Method( string instancepath )
- {
- int i = -1;
- try{
- string ip = instancepath;
- if (this.InstancePath != "") { ip = this.InstancePath; }
- else { ip = "MSFT_NetFirewallRule=@"; }
- ManagementScope scope = new ManagementScope("ROOT\\StandardCimv2");
- ManagementObject mo = new ManagementObject(scope, new ManagementPath(ip), new ObjectGetOptions());
- mo.Scope.Options.EnablePrivileges = true;
- ManagementBaseObject param = mo.InvokeMethod( "EnumerateFull" , null , null );
- i = Convert.ToInt32(param[ "ReturnValue" ].ToString());
- mo.Dispose();
- } catch (Exception ex) { LogError(ex); }
- return i;
- }
- #endregion public int Execute_EnumerateFull_Method()
- #region Get_All_MSFT_NetFirewallRule_Objects()
- ///===================================================================================================
- ///
- /// Get_All_MSFT_NetFirewallRule_Objects()
- ///
- ///===================================================================================================
- /// <summary>
- /// Returns an ArrayList of 'MSFT_NetFirewallRule' objects with all fields filled
- /// </summary>
- /// <returns>ArrayList of 'MSFT_NetFirewallRule' objects</returns>
- public ArrayList Get_All_MSFT_NetFirewallRule_Objects()
- {
- ArrayList the_ArrayList = new ArrayList();
- ConnectionOptions co = new ConnectionOptions();
- co.EnablePrivileges = true;
- co.Impersonation = ImpersonationLevel.Impersonate;
- co.Authentication = AuthenticationLevel.PacketPrivacy;
- co.Timeout = new TimeSpan(0, 0, 10);
- if(!this._islocalconnection)
- {
- co.Username = this._username;
- co.Password = this._password;
- co.Authority = "ntlmdomain:" + this._hostname;
- }
- ManagementScope ms = new ManagementScope("\\\\"+ this._hostname + "\\" + this._namespace , co);
- ms.Connect();
- while (!ms.IsConnected)
- {
- System.Threading.Thread.Sleep(1);
- }
- if( !ms.IsConnected )
- {
- LogWarning( "Could not connect to management scope!" + ms.Path );
- }
- else
- {
- ObjectQuery oQuery = new ObjectQuery(this._wmiquery);
- ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, oQuery);
- searcher.Options.UseAmendedQualifiers = false;
- ManagementObjectCollection moc = searcher.Get();
- foreach (ManagementObject mo in moc)
- {
- MSFT_NetFirewallRule x = new MSFT_NetFirewallRule();
- x._instancepath = mo.Path.RelativePath;
- x._knownhostid = this.KnownHostID;
- x._hostname = this._hostname;
- try
- {
- x.varAction = Convert.ToUInt16(mo.GetPropertyValue("Action")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varCaption = Convert.ToString(mo.GetPropertyValue("Caption")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varCommonName = Convert.ToString(mo.GetPropertyValue("CommonName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varConditionListType = Convert.ToUInt16(mo.GetPropertyValue("ConditionListType")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varCreationClassName = Convert.ToString(mo.GetPropertyValue("CreationClassName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varDescription = Convert.ToString(mo.GetPropertyValue("Description")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varDirection = Convert.ToUInt16(mo.GetPropertyValue("Direction")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varDisplayGroup = Convert.ToString(mo.GetPropertyValue("DisplayGroup")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varDisplayName = Convert.ToString(mo.GetPropertyValue("DisplayName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varEdgeTraversalPolicy = Convert.ToUInt16(mo.GetPropertyValue("EdgeTraversalPolicy")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varElementName = Convert.ToString(mo.GetPropertyValue("ElementName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varEnabled = Convert.ToUInt16(mo.GetPropertyValue("Enabled")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- UInt16[] var = new UInt16[1];
- var = (UInt16[])mo.GetPropertyValue("EnforcementStatus"); //4762 Type:UInt16 Array?:True
- x.varEnforcementStatus = var;
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varExecutionStrategy = Convert.ToUInt16(mo.GetPropertyValue("ExecutionStrategy")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varInstanceID = Convert.ToString(mo.GetPropertyValue("InstanceID")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varLocalOnlyMapping = Convert.ToBoolean(mo.GetPropertyValue("LocalOnlyMapping")); //todo: 4779 Type:Boolean Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varLooseSourceMapping = Convert.ToBoolean(mo.GetPropertyValue("LooseSourceMapping")); //todo: 4779 Type:Boolean Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varMandatory = Convert.ToBoolean(mo.GetPropertyValue("Mandatory")); //todo: 4779 Type:Boolean Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varOwner = Convert.ToString(mo.GetPropertyValue("Owner")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPlatforms = ConvertType.MakeStorableArrayFromManagementBaseObject( mo.GetPropertyValue("Platforms") ).Split('|'); //4768 Type:String Array?:True
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyDecisionStrategy = Convert.ToUInt16(mo.GetPropertyValue("PolicyDecisionStrategy")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyKeywords = ConvertType.MakeStorableArrayFromManagementBaseObject( mo.GetPropertyValue("PolicyKeywords") ).Split('|'); //4768 Type:String Array?:True
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyRoles = ConvertType.MakeStorableArrayFromManagementBaseObject( mo.GetPropertyValue("PolicyRoles") ).Split('|'); //4768 Type:String Array?:True
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyRuleName = Convert.ToString(mo.GetPropertyValue("PolicyRuleName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyStoreSource = Convert.ToString(mo.GetPropertyValue("PolicyStoreSource")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPolicyStoreSourceType = Convert.ToUInt16(mo.GetPropertyValue("PolicyStoreSourceType")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPrimaryStatus = Convert.ToUInt16(mo.GetPropertyValue("PrimaryStatus")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varPriority = Convert.ToUInt16(mo.GetPropertyValue("Priority")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varProfiles = Convert.ToUInt16(mo.GetPropertyValue("Profiles")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varRuleGroup = Convert.ToString(mo.GetPropertyValue("RuleGroup")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varRuleUsage = Convert.ToString(mo.GetPropertyValue("RuleUsage")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varSequencedActions = Convert.ToUInt16(mo.GetPropertyValue("SequencedActions")); //todo: 4779 Type:UInt16 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varStatus = Convert.ToString(mo.GetPropertyValue("Status")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varStatusCode = Convert.ToUInt32(mo.GetPropertyValue("StatusCode")); //todo: 4779 Type:UInt32 Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varSystemCreationClassName = Convert.ToString(mo.GetPropertyValue("SystemCreationClassName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- try
- {
- x.varSystemName = Convert.ToString(mo.GetPropertyValue("SystemName")); //todo: 4779 Type:String Array?:False
- }
- catch(Exception ex)
- {
- LogError(ex);
- }
- the_ArrayList.Add(x);
- }
- searcher.Dispose();
- moc.Dispose();
- }
- return the_ArrayList;
- }
- #endregion
- ///====================================================================================================
- ///
- /// public ManagementObjectCollection GetInstances( ManagementClass m )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a managementobjectcollection from the selected class
- ///</summary>
- ///<param name="m">ManagementClass</param>
- ///<returns>ManagementObjectCollection</returns>
- public ManagementObjectCollection GetInstances( ManagementClass m )
- {
- ManagementPath mgtPath = new ManagementPath(m.Path.Path);
- ConnectionOptions co = new ConnectionOptions();
- co.Authentication = AuthenticationLevel.Packet;
- co.EnablePrivileges = true;
- co.Timeout = TimeSpan.MaxValue;
- if(this._username != ""){ co.Username = this._username; }
- if(this._password != ""){ co.Password = this._password; }
- ManagementScope ms = new ManagementScope("\\\\"+ this._hostname + "\\" + this._namespace , co);
- ms.Options.Timeout = TimeSpan.MaxValue;
- ms.Options.Impersonation = ImpersonationLevel.Impersonate;
- ms.Options.EnablePrivileges = true;
- ms.Connect();
- if( !ms.IsConnected )
- {
- LogWarning( "Could not connect to management scope!" + ms.Path );
- }
- SelectQuery selQuery = new SelectQuery( m.Path.ClassName );
- ManagementObjectSearcher s = new ManagementObjectSearcher( ms , selQuery );
- s.Options.UseAmendedQualifiers = true;
- s.Options.DirectRead = true;
- s.Options.EnumerateDeep = true;
- return s.Get();
- }
- ///====================================================================================================
- ///===================================================================================================
- ///
- /// public ManagementObject GetFirstInstance( string p_classname, string p_SysRelPath )
- ///
- ///===================================================================================================
- ///<summary>
- /// Get a ManagementObject by its key property value
- ///</summary>
- /// Win32_DiskDrive, DeviceID="\\.\PHYSICALDRIVE0"
- /// Win32_NetworkAdapter, DeviceID="0"
- /// <param name="p_ClassName">WMI Class Name</param>
- /// <param name="p_RelPath">DeviceID="CPU0" (Example)</param>
- ///<returns>ManagementObject</returns>
- public ManagementObject GetFirstInstance( string p_classname, string p_SysRelPath )
- {
- ManagementPath mgtPath = new ManagementPath(p_classname);
- ConnectionOptions co = new ConnectionOptions();
- co.Authentication = AuthenticationLevel.Packet;
- co.EnablePrivileges = true;
- co.Timeout = TimeSpan.MaxValue;
- if(this._username != ""){ co.Username = this._username; }
- if(this._password != ""){ co.Password = this._password; }
- ManagementScope ms = new ManagementScope("\\\\"+ this._hostname + "\\" + this._namespace , co);
- ms.Options.Timeout = TimeSpan.MaxValue;
- ms.Options.Impersonation = ImpersonationLevel.Impersonate;
- ms.Options.EnablePrivileges = true;
- ms.Connect();
- if( !ms.IsConnected )
- {
- LogWarning( "Could not connect to management scope!" + ms.Path );
- }
- SelectQuery selQuery = new SelectQuery( p_classname , p_SysRelPath );
- ManagementObjectSearcher moSearcher = new ManagementObjectSearcher( ms , selQuery );
- moSearcher.Options.UseAmendedQualifiers = false;
- ManagementObject mo = new ManagementObject();
- foreach( ManagementObject mob in moSearcher.Get() )
- {
- mo = mob;
- break;
- }
- return mo;
- }
- ///===================================================================================================
- ///
- /// public ManagementObject GetByPath( string p_SysFullPath )
- ///
- ///===================================================================================================
- ///<summary>
- /// Get a ManagementObject by its key property value
- ///</summary>
- /// Win32_DiskDrive, DeviceID="\\.\PHYSICALDRIVE0"
- /// Win32_NetworkAdapter, DeviceID="0"
- /// etc...
- /// <param name="p_ClassName">WMI Class Name</param>
- /// <param name="p_SysRelPath">DeviceID="CPU0" (Example)</param>
- ///<returns>ManagementObject</returns>
- public ManagementObject GetInstanceByPath(string p_classname, string p_SysRelPath )
- {
- ManagementPath mgtPath = new ManagementPath(p_classname);
- ConnectionOptions co = new ConnectionOptions();
- co.Authentication = AuthenticationLevel.Packet;
- co.EnablePrivileges = true;
- co.Timeout = TimeSpan.MaxValue;
- if(this._username != ""){ co.Username = this._username; }
- if(this._password != ""){ co.Password = this._password; }
- ManagementScope ms = new ManagementScope("\\\\"+ this._hostname + "\\" + this._namespace , co);
- ms.Options.Timeout = TimeSpan.MaxValue;
- ms.Options.Impersonation = ImpersonationLevel.Impersonate;
- ms.Options.EnablePrivileges = true;
- ms.Connect();
- if( !ms.IsConnected )
- {
- LogWarning( "Could not connect to management scope!" + ms.Path );
- }
- SelectQuery selQuery = new SelectQuery( p_classname , p_SysRelPath );
- ManagementObjectSearcher moSearcher = new ManagementObjectSearcher( ms , selQuery );
- moSearcher.Options.UseAmendedQualifiers = true;
- ManagementObject mob = new ManagementObject();
- foreach( ManagementObject mo in moSearcher.Get() )
- {
- mob = mo;
- }
- return mob;
- }
- ///====================================================================================================
- #region InstancesToHTML()
- ///===================================================================================================
- ///
- /// public static string InstancesToHTML()
- ///
- ///===================================================================================================
- /// <summary>
- /// Returns a html string of all instances of this class
- /// </summary>
- /// <returns>string html</returns>
- public static string InstancesToHtml()
- {
- ConnectionOptions co = new ConnectionOptions();
- co.EnablePrivileges = true;
- co.Impersonation = ImpersonationLevel.Impersonate;
- co.Authentication = AuthenticationLevel.PacketPrivacy;
- ManagementScope ms = new ManagementScope( "\\\\.\\\\root\\StandardCimv2", co );
- ObjectQuery oQuery = new ObjectQuery( "select * from MSFT_NetFirewallRule" );
- ManagementObjectSearcher searcher = new ManagementObjectSearcher( ms , oQuery );
- ManagementObjectCollection moc = searcher.Get();
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.AppendLine();
- sb.AppendLine( "<!-- generated by hydra-->" );
- sb.AppendLine( " < table border=1 cellpadding=5 cellspacing=0>" );
- sb.AppendLine( " < tr><td colspan=2><strong>" + searcher.Scope.Path.Path + "</strong></td></tr>" );
- foreach( ManagementObject mo in moc )
- {
- sb.AppendLine( "" );
- sb.AppendLine( " < tr><td colspan=2><strong>" + mo.Path.Path.ToString() + "</strong></td></tr>" );
- sb.AppendLine( " < tr><td>Action</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Action") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Caption</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Caption") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>CommonName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("CommonName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>ConditionListType</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("ConditionListType") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>CreationClassName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("CreationClassName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Description</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Description") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Direction</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Direction") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>DisplayGroup</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("DisplayGroup") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>DisplayName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("DisplayName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>EdgeTraversalPolicy</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("EdgeTraversalPolicy") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>ElementName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("ElementName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Enabled</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Enabled") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>EnforcementStatus</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("EnforcementStatus") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>ExecutionStrategy</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("ExecutionStrategy") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>InstanceID</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("InstanceID") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>LocalOnlyMapping</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("LocalOnlyMapping") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>LooseSourceMapping</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("LooseSourceMapping") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Mandatory</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Mandatory") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Owner</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Owner") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Platforms</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Platforms") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyDecisionStrategy</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyDecisionStrategy") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyKeywords</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyKeywords") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyRoles</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyRoles") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyRuleName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyRuleName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyStoreSource</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyStoreSource") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PolicyStoreSourceType</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PolicyStoreSourceType") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>PrimaryStatus</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("PrimaryStatus") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Priority</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Priority") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Profiles</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Profiles") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>RuleGroup</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("RuleGroup") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>RuleUsage</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("RuleUsage") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>SequencedActions</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("SequencedActions") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>Status</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("Status") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>StatusCode</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("StatusCode") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>SystemCreationClassName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("SystemCreationClassName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td>SystemName</td><td>" + ConvertType.ManagementBaseObjectToString( mo.GetPropertyValue("SystemName") ) + "</td></tr>" );
- sb.AppendLine( " < tr><td colspan=2> </td></tr>" );
- }
- sb.AppendLine("</table>" );
- sb.AppendLine();
- searcher.Dispose();
- moc.Dispose();
- return sb.ToString();
- }
- #endregion
- #region LogError( Exception ex)
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogError(Exception ex)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- /// <summary>
- /// Log Errors
- /// </summary>
- public static void LogError(Exception ex)
- {
- EventLog Log = new EventLog( "Hydra" , ".", "MSFT_NetFirewallRule");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(ex.ToString(), EventLogEntryType.Error, 420 );
- }
- #endregion
- #region LogError(Exception ex, int evt_id )
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogError(Exception ex, int evt_id)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- public static void LogError(Exception ex, int evt_id)
- {
- EventLog Log = new EventLog( "Hydra" , ".", "MSFT_NetFirewallRule");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(ex.ToString(), EventLogEntryType.Error, evt_id );
- }
- #endregion
- #region LogWarning(string info)
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogWarning(string info)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- /// <summary>
- /// Log Warning
- /// </summary>
- public static void LogWarning(string info)
- {
- EventLog Log = new EventLog("Hydra",".", "Hydra");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(info, EventLogEntryType.Warning, 420 );
- }
- #endregion
- #region LogWarning(string info, int evt_id)
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogWarning(string info, int evt_id)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- /// <summary>
- /// Log Warning
- /// </summary>
- public static void LogWarning(string info, int evt_id)
- {
- EventLog Log = new EventLog("Hydra",".", "Hydra");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(info, EventLogEntryType.Warning, evt_id );
- }
- #endregion
- #region LogInfo(string info)
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogInfo(string info)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- /// <summary>
- /// Log Information
- /// </summary>
- public static void LogInfo(string info)
- {
- EventLog Log = new EventLog("Hydra",".", "Hydra");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(info, EventLogEntryType.Information, 420 );
- }
- #endregion
- #region LogInfo(string info, int evt_id)
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- ///
- /// public static void LogInfo(string info, int evt_id)
- ///
- ///-=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=--=<oo>=-
- /// <summary>
- /// Log Information
- /// </summary>
- public static void LogInfo(string info, int evt_id)
- {
- EventLog Log = new EventLog("Hydra",".", "Hydra");
- if (!EventLog.SourceExists("MSFT_NetFirewallRule"))
- {
- EventLog.CreateEventSource("MSFT_NetFirewallRule", "Hydra");
- }
- Log.Source = "MSFT_NetFirewallRule";
- Log.WriteEntry(info, EventLogEntryType.Information, evt_id );
- }
- #endregion
- #region Database Helper Methods
- ///====================================================================================================
- ///
- /// public void InsertIntoDatabase(string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// insert this "MSFT_NetFirewallRule" into the database
- ///</summary>
- public void InsertIntoDatabase(string DatabaseConnectionString )
- {
- System.Data.SqlClient.SqlParameter[] p = new SqlParameter[38];
- p[0] = new SqlParameter("@HostName", SqlDbType.NVarChar, 255);
- try
- {
- p[0].Value = this.HostName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[1] = new SqlParameter("@KnownHostID", SqlDbType.BigInt);
- if(this.KnownHostID == -9 )
- { throw new ApplicationException("Known Host ID was not set when trying to insert into the database"); }
- try
- {
- p[1].Value = this.KnownHostID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[2] = new SqlParameter("@Action", SqlDbType.BigInt);
- try
- {
- p[2].Value = Convert.ToInt64(this.varAction);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[2].Value = 0;
- }
- p[3] = new SqlParameter("@Caption", SqlDbType.NVarChar, 255 );
- try
- {
- p[3].Value = this.varCaption;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[3].Value = "";
- }
- p[4] = new SqlParameter("@CommonName", SqlDbType.NVarChar, 255 );
- try
- {
- p[4].Value = this.varCommonName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[4].Value = "";
- }
- p[5] = new SqlParameter("@ConditionListType", SqlDbType.BigInt);
- try
- {
- p[5].Value = Convert.ToInt64(this.varConditionListType);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[5].Value = 0;
- }
- p[6] = new SqlParameter("@CreationClassName", SqlDbType.NVarChar, 255 );
- try
- {
- p[6].Value = this.varCreationClassName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[6].Value = "";
- }
- p[7] = new SqlParameter("@Description", SqlDbType.NVarChar, 255 );
- try
- {
- p[7].Value = this.varDescription;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[7].Value = "";
- }
- p[8] = new SqlParameter("@Direction", SqlDbType.BigInt);
- try
- {
- p[8].Value = Convert.ToInt64(this.varDirection);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[8].Value = 0;
- }
- p[9] = new SqlParameter("@DisplayGroup", SqlDbType.NVarChar, 255 );
- try
- {
- p[9].Value = this.varDisplayGroup;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[9].Value = "";
- }
- p[10] = new SqlParameter("@DisplayName", SqlDbType.NVarChar, 255 );
- try
- {
- p[10].Value = this.varDisplayName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[10].Value = "";
- }
- p[11] = new SqlParameter("@EdgeTraversalPolicy", SqlDbType.BigInt);
- try
- {
- p[11].Value = Convert.ToInt64(this.varEdgeTraversalPolicy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[11].Value = 0;
- }
- p[12] = new SqlParameter("@ElementName", SqlDbType.NVarChar, 255 );
- try
- {
- p[12].Value = this.varElementName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[12].Value = "";
- }
- p[13] = new SqlParameter("@Enabled", SqlDbType.BigInt);
- try
- {
- p[13].Value = Convert.ToInt64(this.varEnabled);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[13].Value = 0;
- }
- p[14] = new SqlParameter("@EnforcementStatus", SqlDbType.NVarChar, 255 );
- try
- {
- p[14].Value = ConvertType.MakeStorableArrayFromManagementBaseObject( this.varEnforcementStatus ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[14].Value = "";
- }
- p[15] = new SqlParameter("@ExecutionStrategy", SqlDbType.BigInt);
- try
- {
- p[15].Value = Convert.ToInt64(this.varExecutionStrategy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[15].Value = 0;
- }
- p[16] = new SqlParameter("@InstanceID", SqlDbType.NVarChar, 255 );
- try
- {
- p[16].Value = this.varInstanceID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[16].Value = "";
- }
- p[17] = new SqlParameter("@LocalOnlyMapping", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varLocalOnlyMapping) == true)
- {
- p[17].Value = 1;
- }
- else
- {
- p[17].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[17].Value = 0;
- }
- p[18] = new SqlParameter("@LooseSourceMapping", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varLooseSourceMapping) == true)
- {
- p[18].Value = 1;
- }
- else
- {
- p[18].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[18].Value = 0;
- }
- p[19] = new SqlParameter("@Mandatory", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varMandatory) == true)
- {
- p[19].Value = 1;
- }
- else
- {
- p[19].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[19].Value = 0;
- }
- p[20] = new SqlParameter("@Owner", SqlDbType.NVarChar, 255 );
- try
- {
- p[20].Value = this.varOwner;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[20].Value = "";
- }
- p[21] = new SqlParameter("@Platforms", SqlDbType.NVarChar, 255 );
- try
- {
- p[21].Value = ConvertType.MakeStorableArrayFromManagementBaseObject( this.varPlatforms ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[21].Value = "";
- }
- p[22] = new SqlParameter("@PolicyDecisionStrategy", SqlDbType.BigInt);
- try
- {
- p[22].Value = Convert.ToInt64(this.varPolicyDecisionStrategy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[22].Value = 0;
- }
- p[23] = new SqlParameter("@PolicyKeywords", SqlDbType.NVarChar, 255 );
- try
- {
- p[23].Value = ConvertType.MakeStorableArrayFromManagementBaseObject( this.varPolicyKeywords ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[23].Value = "";
- }
- p[24] = new SqlParameter("@PolicyRoles", SqlDbType.NVarChar, 255 );
- try
- {
- p[24].Value = ConvertType.MakeStorableArrayFromManagementBaseObject( this.varPolicyRoles ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[24].Value = "";
- }
- p[25] = new SqlParameter("@PolicyRuleName", SqlDbType.NVarChar, 255 );
- try
- {
- p[25].Value = this.varPolicyRuleName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[25].Value = "";
- }
- p[26] = new SqlParameter("@PolicyStoreSource", SqlDbType.NVarChar, 255 );
- try
- {
- p[26].Value = this.varPolicyStoreSource;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[26].Value = "";
- }
- p[27] = new SqlParameter("@PolicyStoreSourceType", SqlDbType.BigInt);
- try
- {
- p[27].Value = Convert.ToInt64(this.varPolicyStoreSourceType);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[27].Value = 0;
- }
- p[28] = new SqlParameter("@PrimaryStatus", SqlDbType.BigInt);
- try
- {
- p[28].Value = Convert.ToInt64(this.varPrimaryStatus);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[28].Value = 0;
- }
- p[29] = new SqlParameter("@Priority", SqlDbType.BigInt);
- try
- {
- p[29].Value = Convert.ToInt64(this.varPriority);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[29].Value = 0;
- }
- p[30] = new SqlParameter("@Profiles", SqlDbType.BigInt);
- try
- {
- p[30].Value = Convert.ToInt64(this.varProfiles);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[30].Value = 0;
- }
- p[31] = new SqlParameter("@RuleGroup", SqlDbType.NVarChar, 255 );
- try
- {
- p[31].Value = this.varRuleGroup;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[31].Value = "";
- }
- p[32] = new SqlParameter("@RuleUsage", SqlDbType.NVarChar, 255 );
- try
- {
- p[32].Value = this.varRuleUsage;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[32].Value = "";
- }
- p[33] = new SqlParameter("@SequencedActions", SqlDbType.BigInt);
- try
- {
- p[33].Value = Convert.ToInt64(this.varSequencedActions);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[33].Value = 0;
- }
- p[34] = new SqlParameter("@Status", SqlDbType.NVarChar, 255 );
- try
- {
- p[34].Value = this.varStatus;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[34].Value = "";
- }
- p[35] = new SqlParameter("@StatusCode", SqlDbType.BigInt);
- try
- {
- p[35].Value = Convert.ToInt64(this.varStatusCode);
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[35].Value = 0;
- }
- p[36] = new SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar, 255 );
- try
- {
- p[36].Value = this.varSystemCreationClassName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[36].Value = "";
- }
- p[37] = new SqlParameter("@SystemName", SqlDbType.NVarChar, 255 );
- try
- {
- p[37].Value = this.varSystemName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- p[37].Value = "";
- }
- if(!Data.HydraDatabase.DatabaseIsOnline())
- {
- Logging.LogWarning("Hydra Database is Offline!!!", 911);
- }
- else
- {
- Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NetFirewallRule_INSERT", p);
- }
- }
- ///====================================================================================================
- ///
- /// public void UpdateToDatabase( string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// update this instance in the database
- ///</summary>
- public void UpdateToDatabase( string DatabaseConnectionString )
- {
- System.Data.SqlClient.SqlParameter[] p = new SqlParameter[38];
- p[0] = new SqlParameter("@HydraID", SqlDbType.BigInt);
- p[0].Value = this.HydraID;
- p[1] = new SqlParameter("@HostName", SqlDbType.NVarChar, 255);
- p[1].Value = this.HostName;
- p[2] = new SqlParameter("@Action", SqlDbType.BigInt);
- try
- {
- p[2].Value = Convert.ToInt64(this.varAction);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[3] = new SqlParameter("@Caption", SqlDbType.NVarChar, 255 );
- try
- {
- p[3].Value = this.varCaption;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[4] = new SqlParameter("@CommonName", SqlDbType.NVarChar, 255 );
- try
- {
- p[4].Value = this.varCommonName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[5] = new SqlParameter("@ConditionListType", SqlDbType.BigInt);
- try
- {
- p[5].Value = Convert.ToInt64(this.varConditionListType);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[6] = new SqlParameter("@CreationClassName", SqlDbType.NVarChar, 255 );
- try
- {
- p[6].Value = this.varCreationClassName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[7] = new SqlParameter("@Description", SqlDbType.NVarChar, 255 );
- try
- {
- p[7].Value = this.varDescription;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[8] = new SqlParameter("@Direction", SqlDbType.BigInt);
- try
- {
- p[8].Value = Convert.ToInt64(this.varDirection);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[9] = new SqlParameter("@DisplayGroup", SqlDbType.NVarChar, 255 );
- try
- {
- p[9].Value = this.varDisplayGroup;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[10] = new SqlParameter("@DisplayName", SqlDbType.NVarChar, 255 );
- try
- {
- p[10].Value = this.varDisplayName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[11] = new SqlParameter("@EdgeTraversalPolicy", SqlDbType.BigInt);
- try
- {
- p[11].Value = Convert.ToInt64(this.varEdgeTraversalPolicy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[12] = new SqlParameter("@ElementName", SqlDbType.NVarChar, 255 );
- try
- {
- p[12].Value = this.varElementName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[13] = new SqlParameter("@Enabled", SqlDbType.BigInt);
- try
- {
- p[13].Value = Convert.ToInt64(this.varEnabled);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[14] = new SqlParameter("@EnforcementStatus", SqlDbType.NVarChar, 255 );
- try
- {
- p[14].Value = this.varEnforcementStatus;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[15] = new SqlParameter("@ExecutionStrategy", SqlDbType.BigInt);
- try
- {
- p[15].Value = Convert.ToInt64(this.varExecutionStrategy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[16] = new SqlParameter("@InstanceID", SqlDbType.NVarChar, 255 );
- try
- {
- p[16].Value = this.varInstanceID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[17] = new SqlParameter("@LocalOnlyMapping", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varLocalOnlyMapping) == true)
- {
- p[17].Value = 1;
- }
- else
- {
- p[17].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[18] = new SqlParameter("@LooseSourceMapping", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varLooseSourceMapping) == true)
- {
- p[18].Value = 1;
- }
- else
- {
- p[18].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[19] = new SqlParameter("@Mandatory", SqlDbType.Bit);
- try
- {
- if(Convert.ToBoolean(this.varMandatory) == true)
- {
- p[19].Value = 1;
- }
- else
- {
- p[19].Value = 0;
- }
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[20] = new SqlParameter("@Owner", SqlDbType.NVarChar, 255 );
- try
- {
- p[20].Value = this.varOwner;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[21] = new SqlParameter("@Platforms", SqlDbType.NVarChar, 255 );
- try
- {
- p[21].Value = this.varPlatforms;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[22] = new SqlParameter("@PolicyDecisionStrategy", SqlDbType.BigInt);
- try
- {
- p[22].Value = Convert.ToInt64(this.varPolicyDecisionStrategy);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[23] = new SqlParameter("@PolicyKeywords", SqlDbType.NVarChar, 255 );
- try
- {
- p[23].Value = this.varPolicyKeywords;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[24] = new SqlParameter("@PolicyRoles", SqlDbType.NVarChar, 255 );
- try
- {
- p[24].Value = this.varPolicyRoles;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[25] = new SqlParameter("@PolicyRuleName", SqlDbType.NVarChar, 255 );
- try
- {
- p[25].Value = this.varPolicyRuleName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[26] = new SqlParameter("@PolicyStoreSource", SqlDbType.NVarChar, 255 );
- try
- {
- p[26].Value = this.varPolicyStoreSource;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[27] = new SqlParameter("@PolicyStoreSourceType", SqlDbType.BigInt);
- try
- {
- p[27].Value = Convert.ToInt64(this.varPolicyStoreSourceType);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[28] = new SqlParameter("@PrimaryStatus", SqlDbType.BigInt);
- try
- {
- p[28].Value = Convert.ToInt64(this.varPrimaryStatus);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[29] = new SqlParameter("@Priority", SqlDbType.BigInt);
- try
- {
- p[29].Value = Convert.ToInt64(this.varPriority);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[30] = new SqlParameter("@Profiles", SqlDbType.BigInt);
- try
- {
- p[30].Value = Convert.ToInt64(this.varProfiles);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[31] = new SqlParameter("@RuleGroup", SqlDbType.NVarChar, 255 );
- try
- {
- p[31].Value = this.varRuleGroup;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[32] = new SqlParameter("@RuleUsage", SqlDbType.NVarChar, 255 );
- try
- {
- p[32].Value = this.varRuleUsage;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[33] = new SqlParameter("@SequencedActions", SqlDbType.BigInt);
- try
- {
- p[33].Value = Convert.ToInt64(this.varSequencedActions);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[34] = new SqlParameter("@Status", SqlDbType.NVarChar, 255 );
- try
- {
- p[34].Value = this.varStatus;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[35] = new SqlParameter("@StatusCode", SqlDbType.BigInt);
- try
- {
- p[35].Value = Convert.ToInt64(this.varStatusCode);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[36] = new SqlParameter("@SystemCreationClassName", SqlDbType.NVarChar, 255 );
- try
- {
- p[36].Value = this.varSystemCreationClassName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- p[37] = new SqlParameter("@SystemName", SqlDbType.NVarChar, 255 );
- try
- {
- p[37].Value = this.varSystemName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- Hydra.Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure, "MSFT_NetFirewallRule_UPDATE", p);
- }
- ///====================================================================================================
- ///
- /// public static void DELETE_BY_HYDRA_ID( string DatabaseConnectionString, Int64 HydraID )
- ///
- ///====================================================================================================
- ///<summary>
- /// Delete this instance from the database
- ///</summary>
- public static void DELETE_BY_HYDRA_ID( string DatabaseConnectionString, Int64 HydraID )
- {
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HydraID", SqlDbType.BigInt);
- try
- {
- p[0].Value = HydraID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- Hydra.Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_DELETE_BY_HYDRA_ID", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- }
- ///====================================================================================================
- ///
- /// public static void MSFT_NetFirewallRule_DELETE_BY_KNOWN_HOST_ID( double HostID, string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Delete this instance from the database
- ///</summary>
- public static void MSFT_NetFirewallRule_DELETE_BY_KNOWN_HOST_ID( double HostID, string DatabaseConnectionString )
- {
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@KnownHostID", SqlDbType.BigInt);
- try
- {
- p[0].Value = HostID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NetFirewallRule_DELETE_BY_KNOWN_HOST_ID", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- }
- ///====================================================================================================
- ///
- /// public static void Delete_From_Database_By_HostName( string DatabaseConnectionString, string HostName )
- ///
- ///====================================================================================================
- ///<summary>
- /// Delete this instance from the database
- ///</summary>
- public static void Delete_From_Database_By_HostName( string DatabaseConnectionString, string HostName )
- {
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HostName", SqlDbType.NVarChar, 255);
- try
- {
- p[0].Value = HostName;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- Hydra.Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_DELETE_BY_HOSTNAME", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- }
- ///====================================================================================================
- ///
- /// public static void DELETE_ALL( string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Delete this instance from the database
- ///</summary>
- public static void DELETE_ALL_FROM_DATABASE( string DatabaseConnectionString )
- {
- try
- {
- Hydra.Data.SqlHelper.ExecuteNonQuery( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_DELETE_ALL");
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- }
- ///====================================================================================================
- ///
- /// public static DataSet Get_DataSet_By_HydraID( int HydraID, string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a DataSet representing this instance from the database
- ///</summary>
- public static DataSet Get_DataSet_By_Hydra_ID(int HydraID, string DatabaseConnectionString )
- {
- DataSet ds = new DataSet();
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HydraID", SqlDbType.BigInt);
- try
- {
- p[0].Value = HydraID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- ds =Hydra.Data.SqlHelper.ExecuteDataset( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_SELECTBYID", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return ds;
- }
- ///====================================================================================================
- ///
- /// public static DataSet Get_DataSet_By_HOST_ID( double HostID, string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a DataSet representing this instance from the database
- ///</summary>
- public static DataSet Get_DataSet_By_Host_ID(double HostID, string DatabaseConnectionString )
- {
- DataSet ds = new DataSet();
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HostID", SqlDbType.BigInt);
- try
- {
- p[0].Value = HostID;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- ds = Hydra.Data.SqlHelper.ExecuteDataset( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_SELECT_BY_HOST_ID", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return ds;
- }
- ///====================================================================================================
- ///
- /// public static DataSet Get_DataSet_ALL( string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a static DataSet representing all instances from the database
- ///</summary>
- public static DataSet Get_DataSet_ALL( string DatabaseConnectionString )
- {
- DataSet ds = new DataSet();
- try
- {
- ds =Hydra.Data.SqlHelper.ExecuteDataset( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_SELECT_ALL" );
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return ds;
- }
- ///====================================================================================================
- ///
- /// public static DataSet Get_DataSet_By_HostName( string phostname, string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a DataSet representing this instance from the database
- ///</summary>
- public static DataSet Get_DataSet_By_HostName( string phostname, string DatabaseConnectionString )
- {
- DataSet ds = new DataSet();
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HostName", SqlDbType.NVarChar, 255);
- try
- {
- p[0].Value = phostname;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- ds =Hydra.Data.SqlHelper.ExecuteDataset( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_SELECT_BY_HOSTNAME", p);
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return ds;
- }
- ///====================================================================================================
- ///
- /// public double Get_Count_By_KNOWN_Host_ID( double hostid, string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a double representing the number of instances in the database
- ///</summary>
- public static double Get_Count_By_KNOWN_Host_ID( double hostid, string DatabaseConnectionString )
- {
- double i = 0;
- SqlParameter[] p = new SqlParameter[1];
- p[0] = new SqlParameter("@HostID", SqlDbType.BigInt);
- try
- {
- p[0].Value = hostid;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- try
- {
- i = Convert.ToInt64(Hydra.Data.SqlHelper.ExecuteScalar( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_COUNT_BY_KNOWN_HOST_ID", p) ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return i;
- }
- ///====================================================================================================
- ///
- /// public static double GetCount( string DatabaseConnectionString )
- ///
- ///====================================================================================================
- ///<summary>
- /// Get a int representing the number of rec in the table
- ///</summary>
- public static long GetCount( string DatabaseConnectionString )
- {
- Int64 i = 0;
- try
- {
- i = Convert.ToInt64(Hydra.Data.SqlHelper.ExecuteScalar( DatabaseConnectionString , CommandType.StoredProcedure,"MSFT_NETFIREWALLRULE_COUNT") ) ;
- }
- catch(Exception exp)
- {
- LogError(exp);
- }
- return i;
- }
- #endregion
- #region Generate SQL Strings
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement