示例#1
0
 private static object InvokeCommand(Command cmd, out IEnumerable <ErrorRecord> pipelineErrors)
 {
     return(AuditConfigUtility.InvokeCommands(new List <Command>
     {
         cmd
     }, out pipelineErrors));
 }
示例#2
0
        internal static void SetAuditConfigurationRule(Workload workload, OrganizationIdParameter organizationId, MultiValuedProperty <AuditableOperations> auditOpsToSet, out IEnumerable <ErrorRecord> pipelineErrors)
        {
            Guid guid;

            if (!AuditPolicyUtility.GetRuleGuidFromWorkload(workload, out guid))
            {
                pipelineErrors = new List <ErrorRecord>();
                return;
            }
            Command command = new Command("Get-AuditConfigurationRule");

            if (organizationId != null)
            {
                command.Parameters.Add("Organization", organizationId);
            }
            command.Parameters.Add("Identity", guid.ToString());
            Command command2 = new Command("Set-AuditConfigurationRule");

            command2.Parameters.Add("AuditOperation", auditOpsToSet);
            AuditConfigUtility.InvokeCommands(new List <Command>
            {
                command,
                command2
            }, out pipelineErrors);
        }
示例#3
0
        internal static AuditConfigurationPolicy NewAuditConfigurationPolicy(Workload workload, OrganizationIdParameter organizationId, out IEnumerable <ErrorRecord> pipelineErrors)
        {
            Command command = new Command("New-AuditConfigurationPolicy");

            if (organizationId != null)
            {
                command.Parameters.Add("Organization", organizationId);
            }
            command.Parameters.Add("Workload", workload);
            return(AuditConfigUtility.InvokeCommand(command, out pipelineErrors) as AuditConfigurationPolicy);
        }
示例#4
0
        internal static AuditConfigurationRule NewAuditConfigurationRule(Workload workload, OrganizationIdParameter organizationId, MultiValuedProperty <AuditableOperations> auditOpsToSet, out IEnumerable <ErrorRecord> pipelineErrors)
        {
            Command command = new Command("New-AuditConfigurationRule");

            if (organizationId != null)
            {
                command.Parameters.Add("Organization", organizationId);
            }
            command.Parameters.Add("Workload", workload);
            command.Parameters.Add("AuditOperation", auditOpsToSet);
            return(AuditConfigUtility.InvokeCommand(command, out pipelineErrors) as AuditConfigurationRule);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     base.PsPolicyPresentationObject = new AuditConfigurationPolicy(this.DataObject)
     {
         Name              = this.policyName,
         Workload          = AuditConfigUtility.GetEffectiveWorkload(this.Workload),
         Enabled           = false,
         Mode              = Mode.Enforce,
         ExchangeBinding   = base.InternalExchangeBindings,
         SharePointBinding = base.InternalSharePointBindings
     };
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
示例#6
0
        internal static AuditConfigurationPolicy GetAuditConfigurationPolicy(Workload workload, OrganizationIdParameter organizationId, out IEnumerable <ErrorRecord> pipelineErrors)
        {
            Guid guid;

            if (!AuditPolicyUtility.GetPolicyGuidFromWorkload(workload, out guid))
            {
                pipelineErrors = new List <ErrorRecord>();
                return(null);
            }
            Command command = new Command("Get-AuditConfigurationPolicy");

            if (organizationId != null)
            {
                command.Parameters.Add("Organization", organizationId);
            }
            command.Parameters.Add("Identity", guid.ToString());
            return(AuditConfigUtility.InvokeCommand(command, out pipelineErrors) as AuditConfigurationPolicy);
        }
示例#7
0
        protected override void InternalProcessRecord()
        {
            Func <ErrorRecord, bool> predicate = (ErrorRecord e) => !(e.Exception is ManagementObjectNotFoundException);

            foreach (Workload workload in AuditConfigUtility.AuditableWorkloads)
            {
                IEnumerable <ErrorRecord> errRecords;
                AuditConfigurationPolicy  auditConfigurationPolicy = AuditConfigUtility.GetAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate) && auditConfigurationPolicy != null)
                {
                    AuditConfigurationRule auditConfigurationRule = AuditConfigUtility.GetAuditConfigurationRule(workload, this.Organization, out errRecords);
                    if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate) && auditConfigurationRule != null)
                    {
                        this.WriteResult(new AuditConfig(workload)
                        {
                            Setting = AuditConfigUtility.ValidateAuditConfigurationRule(workload, auditConfigurationRule),
                            PolicyDistributionStatus = PolicyApplyStatus.Success,
                            DistributionResults      = auditConfigurationPolicy.DistributionResults
                        });
                    }
                }
            }
        }
示例#8
0
        protected override void InternalProcessRecord()
        {
            Func <ErrorRecord, bool> predicate = (ErrorRecord e) => !(e.Exception is ManagementObjectNotFoundException);

            foreach (Workload workload in AuditConfigUtility.AuditableWorkloads)
            {
                AuditSwitchStatus auditSwitch = this.Workload.Contains(workload) ? AuditSwitchStatus.On : AuditSwitchStatus.Off;
                MultiValuedProperty <AuditableOperations> auditOperations = AuditConfigUtility.GetAuditOperations(workload, auditSwitch);
                IEnumerable <ErrorRecord> errRecords;
                AuditConfigurationRule    auditConfigurationRule = AuditConfigUtility.GetAuditConfigurationRule(workload, this.Organization, out errRecords);
                if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate))
                {
                    if (auditConfigurationRule != null)
                    {
                        AuditConfigUtility.SetAuditConfigurationRule(workload, this.Organization, auditOperations, out errRecords);
                        AuditConfigUtility.ValidateErrorRecords(this, errRecords);
                    }
                    else
                    {
                        AuditConfigurationPolicy auditConfigurationPolicy = AuditConfigUtility.GetAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                        if (AuditConfigUtility.ValidateErrorRecords(this, errRecords, predicate))
                        {
                            if (auditConfigurationPolicy == null)
                            {
                                auditConfigurationPolicy = AuditConfigUtility.NewAuditConfigurationPolicy(workload, this.Organization, out errRecords);
                                if (!AuditConfigUtility.ValidateErrorRecords(this, errRecords))
                                {
                                    continue;
                                }
                            }
                            auditConfigurationRule = AuditConfigUtility.NewAuditConfigurationRule(workload, this.Organization, auditOperations, out errRecords);
                            AuditConfigUtility.ValidateErrorRecords(this, errRecords);
                        }
                    }
                }
            }
        }
示例#9
0
 internal static bool ValidateErrorRecords(Cmdlet cmdLet, IEnumerable <ErrorRecord> errRecords)
 {
     return(AuditConfigUtility.ValidateErrorRecords(cmdLet, errRecords, (ErrorRecord err) => true));
 }