The policy core consists of conditions and targets. Moreover, complex targets are defined by additional conditions, as we already showed in the SQL Server security and Policy Based Management – In practice article

政策核心包括条件和目标。 而且,复杂目标是由附加条件定义的,正如我们在《 SQL Server安全性和基于策略的管理–实践》文章中已经说明的那样

Along with predefined properties, conditions can utilize T-SQL queries too. In this article, we’ll describe and provide a step-by-step example for creating an advanced Policy Based Management policy which uses T-SQL within its condition. The example will provide the policy which verifies whether SQL SERVER Agent alerts were reset, which can be a serious security alert that requires further investigation

除了预定义的属性外,条件也可以利用T-SQL查询。 在本文中,我们将描述并提供一个分步示例,以创建高级的基于策略的管理策略,该策略在其条件下使用T-SQL。 该示例将提供用于验证是否重置了SQL SERVER Agent警报的策略,这可能是严重的安全警报,需要进一步调查。

The first thing you need to do when creating a new policy is to declare and create the condition on which the policy is based.

创建新策略时,您需要做的第一件事就是声明并创建该策略所基于的条件。

To create the condition:

要创建条件:

  1. Management node in 对象资源管理器”中展开“ Object Explorer管理”节点
  2. Policy Management node and select the 策略管理”节点,然后在“ New Condition option in the 条件”子节点上下文菜单中选择“ Conditions sub-node context menu新条件”选项。
  3. Type in the condition name (e.g. NumberOfResetAlerts) in the Create New Condition dialog, and select the Server item from the Facets dropdown menu
  4. 在“ 创建新条件”对话框中输入条件名称(例如NumberOfResetAlerts ),然后从“ 构面”下拉菜单中选择“ 服务器”
  5. Click the “…” button next to the empty field in the Expression grid

    单击“ 表达式”网格中空白字段旁边的“…”按钮

  6. This will open the Advanced Edit dialog. Scroll down the Functions and properties list, locate the ExecuteSql() function, and double-click it in order to add it to the Cell value text box

    这将打开“ 高级编辑”对话框。 向下滚动“ 功能和属性”列表,找到ExecuteSql()函数,然后双击以将其添加到“ 单元格值”文本框中

    The ExecuteSql(string returnType, string sqlQuery) value will be shown and ready for additional modification. The ExecuteSql() function has two parameters:

    将显示ExecuteSql(string returnType,string sqlQuery)值,并准备进行其他修改。 ExecuteSql()函数具有两个参数:

    • returnType string variable. Supported types are Numeric, String, Bool, DateTime, and GUIDreturnType字符串变量指定。 支持的类型为数字,字符串,布尔,日期时间和GUID
    • sqlQuery variablesqlQuery变量指定的T-SQL

    The function return value is the first column in the first row of the result set returned by the T-SQL query. Only one column should be specified in the SELECT statement. Any additional columns are ignored. The same applies to returned rows. The rows beyond the first one are not considered. In case the query result is an empty set or NULL, the condition expression built on the ExecuteSql() function will be false

    函数返回值是T-SQL查询返回的结果集第一行中的第一列。 SELECT语句中只能指定一列。 任何其他列都将被忽略。 这同样适用于返回的行。 不考虑第一行以外的行。 如果查询结果为空集或NULL,则基于ExecuteSql()函数构建的条件表达式将为false

    In our example, we’ll use ‘Numeric’ as a type, and ‘SELECT COUNT(*) from sdb.dbo.sysalerts where count_reset_date=0’ T-SQL as a query. The final expression in the Cell value text box will be:

    在我们的示例中,我们将使用'Numeric'作为类型,并使用sdb.dbo.sysalerts中的'SELECT COUNT(*),其中count_reset_date = 0'T -SQL作为查询。 单元格值文本框中的最终表达式将是:

    ExecuteSql(‘Numeric’, ‘SELECT COUNT(*) from msdb.dbo.sysalerts where count_reset_date=0’)

    ExecuteSql('数值','从msdb.dbo.sysalerts中选择COUNT(*),其中count_reset_date = 0')

    Click Ok to save the cell expression value

    单击确定以保存单元格表达式值

  7. This will close the Advanced Edit dialog and return to the New Condition dialog. Select the != operator and type in the 0 as the value.

    这将关闭“高级编辑”对话框,并返回到“新条件”对话框。 选择!=运算符,然后输入0作为值。

    This will complete the condition expression which evaluates whether the msdb.dbo.sysalerts system table holds any records about alerts that were reset at some point in time. Note that the query within the ExecuteSql() function can be modified to meet the requirements, if needed. In addition, the Expression grid can hold multiple rows with different functions and queries in order to narrow down the required condition.

    这将完成条件表达式,该条件表达式将评估msdb.dbo.sysalerts系统表是否保存有关在某个时间点重置的警报的任何记录。 注意,如果需要,可以修改ExecuteSql()函数中的查询以满足要求。 另外,“ 表达式”网格可以容纳具有不同功能和查询的多行,以缩小所需条件的范围。

To create the policy that will use the NumberOfResetAlerts condition:

要创建将使用NumberOfResetAlerts条件的策略:

  1. New Policy option from the context menu of the 策略”节点的上下文菜单中选择“ Policies node. The 新建策略”选项。 “ Create New Policy Dialog will be opened创建新策略”对话框将打开。
  2. Type in the policy name (e.g. ThereAreNoResetAlerts) and select the NumberOfResetAlerts condition from the Check condition dropdown list

    输入策略名称(例如ThereAreNoResetAlerts ),然后从“ 检查条件”下拉列表中选择NumberOfResetAlerts条件

  3. Evaluation Mode dropdown menu. Note that 评估模式下拉菜单设置所需的评估模式。 请注意,该条件中使用的ExecuteSql() used in the condition supports the ExecuteSql()支持On Demand and 按需评估和按On Schedule evaluation modes. 计划评估模式。 不支持On change evaluation modes are not supported变更时评估模式

Depending on the evaluation mode, consider using an appropriate SQL Server Agent alert that can automatically notify you about policy violations and help keep your SQL Server secure.

根据评估模式,考虑使用适当的SQL Server代理警报,该警报可以自动向您通知有关策略违规的情况,并有助于确保SQL Server的安全。

翻译自: https://www.sqlshack.com/sql-server-security-and-policy-based-management-advanced-conditions/

SQL Server安全性和基于策略的管理–高级条件相关推荐

  1. SQL Server 2008基于策略的管理

    基于策略的管理(Policy Based Management),使DBA们可以制定管理策略,并将这些策略应用到服务器.数据库以及数据环境中的其他对象上去.经过精心设计的管理策略可以帮助DBA们对数据 ...

  2. SQL Server 2008 : 基于策略的管理(Policy-Based Management)

    在SQL Server 2008中提出了一套新的管理机制,就是所谓的基于策略的管理(姑且可以称为PBM).它的主要优势如下 按需管理:PBM提供了系统配置的逻辑视图,因此DBA们可以预先定义各自所需要 ...

  3. 【java毕业设计】基于java+Eclipse +SQL Server的工厂进销存管理系统设计与实现(毕业论文+程序源码)——工厂进销存管理系统

    基于java+Eclipse +SQL Server的工厂进销存管理系统设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于java+Eclipse +SQL Server的工厂进销存管理系统 ...

  4. 解决方法:SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正

    解决方法:SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正 参考文章: (1)解决方法:SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正 (2)https: ...

  5. SQL Server 检测到基于一致性的逻辑 I/O 错误

    在做sql server数据库从备份文件.bak中恢复,恢复后,在执行查询时报错:SQL Server 检测到基于一致性的逻辑 I/O 错误 SQL Server 检测到基于一致性的逻辑 I/O 错误 ...

  6. 虚拟环境下对SQL Server安全性的考虑

    在虚拟化环境中运行SQL Server的数据库管理员(DBA)们往往最担心的就是安全问题,但根据专家的观点,其实并无必要.SQL Server在虚拟化世界中的安全问题与传统数据库环境的安全挑战并无太多 ...

  7. 第十八章——基于策略的管理(1)——评估数据库属性

    原文: 第十八章--基于策略的管理(1)--评估数据库属性 前言: 本章包含: 1.评估数据库属性 2.限制数据库对象 介绍: 基于策略的管理(PBM)能帮助DBA管理一个或多个实例,并通过PBM管理 ...

  8. SQL Server 检测到基于一致性的逻辑 I/O 错误.....请执行完整的数据库一致性检查(DBCC CHECKDB)......

    错误信息: SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正确(应为: 0xb11dc661,但实际为: 0x395240ca).在文件 'D:\Program Files\Mi ...

  9. 数据库 SQL Server 检测到基于一致性的逻辑 I/O 错误 页撕裂 执行 读取 期间,发生了该错误 恢复

    [检测] 数据库系统表架构损坏, 用DBCC检测得到如下结果 配置选项 'allow updates' 已从 1 更改为 1.请运行 RECONFIGURE 语句进行安装. 文件激活失败.物理文件名称 ...

最新文章

  1. OS X 要改名为 MacOS 是因为 iOS 10 要来了?
  2. 论文浅尝 | 基于Universal Schema与Memory Network的知识+文本问答
  3. 谈Flash中的鼠标响应
  4. [补档]noip2019集训测试赛(十二)
  5. 打开计算机没显示硬盘分区,电脑新插了一个硬盘没显示怎么办
  6. c语言10的10万次方,在c语言编程中 10的n次方应该怎么表达
  7. 一级导航,二级导航,三级导航介绍
  8. suffix arrary
  9. JavaScript实战——打气球游戏
  10. vue项目echarts通过cdn或npm引入
  11. 游戏地图与场景设计常用名词
  12. java模拟抛物线_小tips:用java模拟小球做抛物线运动
  13. iphone长截图哪个软件好_亲身体验过13款滚动截屏App,谁才是最好用的iPhone长截屏工具?...
  14. PID控制器的优缺点和周期
  15. 基于pyhton3.6-机器学习实战-支持向量机SVM代码解释
  16. 从零开始的技术美术之路(六)色彩空间
  17. 葵花宝典之玩转众包——发包方
  18. 【NLP】第 18 章从零开始训练 Transformer
  19. 【转载】CSDN修改用户名、昵称
  20. 一份全面详细的Android 车载系统开发入门指南与面试题

热门文章

  1. C# 知识点笔记:IEnumerable的使用,利用反射动态调用方法
  2. 【备战NOIP】[算法总结] 二分查找
  3. Python自动化之高级语法单例模式
  4. android:id=@android:id/tabhost 、android:id=@+id/llRoot 、android:id=@id/llRoot 之间的区别...
  5. 下载--保存(下载)文件到本地(.doc .jpg)
  6. 作业帮电脑版在线使用_应届生应聘作业帮的在线辅导老师
  7. redis key/value 前面出现\xac\xed\x00\x05t\x00\x06 已解决
  8. 一个男人具备什么样的条件,才能结婚?
  9. 建议考事业编吗?为什么?
  10. 公司盘点员工,不上班的员工要给钱吗?