随笔 - 229  文章 - 2  评论 - 511  阅读 - 84万

create audit例子

 

复制代码
代码
--setup
USE MASTER
GO
-- Create the server audit
CREATE SERVER AUDIT test_audit
    
TO FILE ( FILEPATH = 
'E:\audit' );
GO
-- Enable the server audit
ALTER SERVER AUDIT test_audit 
WITH (STATE = ON) ;
GO
-- Move to the target database
USE Fortest_lmtopo
GO
CREATE DATABASE AUDIT SPECIFICATION Audit_MEETING_VISITOR
FOR SERVER AUDIT test_audit
ADD (update , INSERT,delete
     
ON lmuser.MEETING_VISITOR by public)--audit these operation executed by any user because all users are inhert from 'public'role
WITH (STATE = ON)
GO
--CREATE DATABASE AUDIT SPECIFICATION Audit_update_Fortest_lmtopo
--
FOR SERVER AUDIT test_audit
--
ADD (DATABASE_OBJECT_ACCESS_GROUP
--
)
--
WITH (STATE = ON)


--query

select a.name as [Action],c.class_type_desc as [ObjectType],f.schema_name,f.object_name,f.statement from
sys.fn_get_audit_file('c:\case\*',default,default) f inner join sys.dm_audit_actions a
on f.action_id=a.action_id inner join sys.dm_audit_class_type_map c on f.class_type=c.class_type
AND c.securable_class_desc = a.class_desc



GO
--clean
go
use Fortest_lmtopo
go
ALTER database AUDIT specification Audit_MEETING_VISITOR with(state=off
go
drop database audit specification Audit_MEETING_VISITOR
go
use master
go
alter server audit test_audit with (state=off)
go
drop server audit test_audit
go

复制代码

 

 

http://technet.microsoft.com/en-us/library/cc280404.aspx

http://www.sqldbatips.com/showarticle.asp?ID=136

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
USE MASTER
GO
-- Create the server audit
CREATE SERVER AUDIT test_audit
TO FILE ( FILEPATH =
'C:\cases\Cluster\116020613677365- SQL server not starting up in cluster' );
GO
-- Enable the server audit
ALTER SERVER AUDIT test_audit
WITH (STATE = ON) ;
GO
 
 
CREATE SERVER AUDIT SPECIFICATION audit_specification_name
FOR SERVER AUDIT test_audit
ADD ( SERVER_PERMISSION_CHANGE_GROUP ) ,
add (SERVER_PRINCIPAL_CHANGE_GROUP)
 WITH ( STATE =  ON )

 

posted on   stswordman  阅读(621)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
< 2010年1月 >
27 28 29 30 31 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6

点击右上角即可分享
微信分享提示