private bool UpdateDiagnosticSettingsForModel(
            DiagnosticSettingsResource settings, AuditModelType model)
        {
            DiagnosticSettingsResource modifiedSettings = UpdateDiagnosticSettings(settings, model);

            if (modifiedSettings == null)
            {
                return(false);
            }

            List <DiagnosticSettingsResource> diagnosticsEnablingAuditCategory = new List <DiagnosticSettingsResource>();

            foreach (DiagnosticSettingsResource existingSettings in model.DiagnosticsEnablingAuditCategory)
            {
                if (!string.Equals(modifiedSettings.Id, existingSettings.Id))
                {
                    diagnosticsEnablingAuditCategory.Add(existingSettings);
                }
                else if (AuditingEndpointsCommunicator.IsAuditCategoryEnabled(modifiedSettings, GetDiagnosticsEnablingAuditCategoryName()))
                {
                    diagnosticsEnablingAuditCategory.Add(modifiedSettings);
                }
            }

            model.DiagnosticsEnablingAuditCategory = diagnosticsEnablingAuditCategory.Any() ? diagnosticsEnablingAuditCategory : null;
            return(true);
        }
Пример #2
0
        internal bool UpdateDiagnosticSettings(
            DiagnosticSettingsResource settings,
            dynamic model)
        {
            DiagnosticSettingsResource updatedSettings;

            if (model is DatabaseBlobAuditingSettingsModel || model is DatabaseAuditModel)
            {
                updatedSettings = Communicator.UpdateDiagnosticSettings(settings,
                                                                        model.ResourceGroupName, model.ServerName, model.DatabaseName);
            }
            else
            {
                updatedSettings = Communicator.UpdateDiagnosticSettings(settings,
                                                                        model.ResourceGroupName, model.ServerName);
            }

            if (updatedSettings == null)
            {
                return(false);
            }

            model.DiagnosticsEnablingAuditCategory =
                AuditingEndpointsCommunicator.IsAuditCategoryEnabled(updatedSettings) ?
                new List <DiagnosticSettingsResource> {
                updatedSettings
            } : null;
            return(true);
        }
Пример #3
0
        internal bool UpdateDiagnosticSettings(
            DiagnosticSettingsResource settings,
            ServerAuditModel model)
        {
            DiagnosticSettingsResource modifiedSettings;

            if (model is DatabaseAuditModel databaseAuditModel)
            {
                modifiedSettings = Communicator.UpdateDiagnosticSettings(settings,
                                                                         databaseAuditModel.ResourceGroupName, databaseAuditModel.ServerName, databaseAuditModel.DatabaseName);
            }
            else
            {
                modifiedSettings = Communicator.UpdateDiagnosticSettings(settings,
                                                                         model.ResourceGroupName, model.ServerName);
            }

            if (modifiedSettings == null)
            {
                return(false);
            }

            List <DiagnosticSettingsResource> diagnosticsEnablingAuditCategory = new List <DiagnosticSettingsResource>();

            foreach (DiagnosticSettingsResource existingSettings in model.DiagnosticsEnablingAuditCategory)
            {
                if (!string.Equals(modifiedSettings.Id, existingSettings.Id))
                {
                    diagnosticsEnablingAuditCategory.Add(existingSettings);
                }
                else if (AuditingEndpointsCommunicator.IsAuditCategoryEnabled(modifiedSettings))
                {
                    diagnosticsEnablingAuditCategory.Add(modifiedSettings);
                }
            }

            model.DiagnosticsEnablingAuditCategory = diagnosticsEnablingAuditCategory.Any() ? diagnosticsEnablingAuditCategory : null;
            return(true);
        }