如何通过 WCF 服务审核 SQL Server 2008 查询?
我想在我的应用程序执行的每个查询中保存任何类型的日志/表。
我知道我可以通过编码来做到这一点(在进行任何查询之前,我在日志表中插入一个新行,其中包含查询和执行它的用户。
我已经读到它可以自动完成,但我不确定它如何与 WCF 服务一起工作。我的意思是每个查询都将由同一个 SQL 用户执行,这对于审计操作不是很有用(我需要知道谁发出了每个查询,并且将根据我的验证用户)自己的用户表)。
您有过类似的情况吗? 进步!
I want to save any kind of log/tables with every query executed by my application.
I know I could do this by coding it (before I make any query, I insert a new row in a log table with the query and the user who is executing it.
I have read it can be done automatically but I'm not sure how can it work with WCF Services. I mean every query is going to be executed by the same SQL user and this wouldn't be very useful for audit operations (I need to know WHO made every query, and users will be validated against my own users tables).
Have you ever had a similar scenario? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为起点,可能值得考虑通过 SQL Server Profiler 来执行此操作。您通常可以在 Management Studio 的“工具”菜单中找到它。
您可以设置跟踪来捕获服务器上运行的所有 SQL。更重要的是,您有无数的过滤器选项可以应用,以便您只捕获您感兴趣的数据(例如DatabaseName、UserName)。
这些信息可以直接存储在 SQL 表中,这样您就可以进行连接。当然,运行这样的操作会导致 SQL 框产生一些开销。
As a starting point it may be worth looking into doing this via SQL Server Profiler. You can normally find this in the Tools Menu in Management Studio.
You can set up a trace to capture all SQL run on a server. More importantly you have a myriad of filter options which can be applied so that you only capture the data you are interested in (e.g. DatabaseName, UserName).
This information can be stored directly in a SQL Table, which should give you the abillity to join onto. Of course running anything like this will result in some overhead on the SQL box.
您可以尝试SQL Server 审核功能。它在服务器和数据库级别审核单个或一组事件。但是,请注意,数据库级别审核仅在 SQL Server Enterprise 和 Developer 版本中可用
You can try the SQL Server Audit feature. It audits singe or groups of events both on server and database level. However, be advised that the database level auditing is available in SQL Server Enterprise and Developer editions only