標籤:ringbuffer 緩衝區 環形緩衝區 security
SQL Server 環形緩衝區(Ring Buffer) -- RING_BUFFER_SECURITY_ERROR 診斷安全相關錯誤
環形緩衝儲存了大量的在過去一段時間段內的安全錯誤資訊,有助於分析SQL Server安全問題。
例如,當你嘗試建立一個SQL登入帳號,並啟用密碼原則,但是提供的密碼不匹配密碼原則。然後,你將會收到一個錯誤訊息說明密碼不匹配。這個錯誤將會儲存在環形緩衝區。當你執行下面的查詢,你將會導致錯誤的SPID以及導致失敗的API名稱。如上面樣本描述的,你會找到NetValidatePwdPolicy錯誤。
如果你轉換ErrorCode的值 0x8C5(=2245)為數值型,然後使用命令列命令NET HELPMSG <number>,你將會看到導致錯誤發生的原因。
650) this.width=650;" title="clip_image001[4]" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image001[4]" src="http://s3.51cto.com/wyfs02/M00/54/1C/wKiom1R4KaPTc-1FAACY92HeGMg587.jpg" height="91" border="0" />
調用的API的名稱對於判斷域帳號相關的安全錯誤是非常有用的,因為它將會調用活動目錄服務相關的函數,這些文檔很容易找到,對於定位問題更為容易。
650) this.width=650;" title="clip_image002[4]" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image002[4]" src="http://s3.51cto.com/wyfs02/M01/54/1C/wKiom1R4KaThyzPiAASTOdcm6iM910.jpg" height="213" border="0" />
對於SQL Server 2005:
SELECT CONVERT (varchar(30), GETDATE(), 121) as runtime,DATEADD (ms, -1 * ((sys.cpu_ticks / sys.cpu_ticks_in_ms) - a.[Record Time]), GETDATE()) AS Notification_time,a.* , sys.ms_ticks AS [Current Time]FROM(SELECTx.value(‘(//Record/Error/ErrorCode)[1]‘, ‘varchar(30)‘) AS [ErrorCode],x.value(‘(//Record/Error/CallingAPIName)[1]‘, ‘varchar(255)‘) AS [CallingAPIName],x.value(‘(//Record/Error/APIName)[1]‘, ‘varchar(255)‘) AS [APIName],x.value(‘(//Record/Error/SPID)[1]‘, ‘int‘) AS [SPID],x.value(‘(//Record/@id)[1]‘, ‘bigint‘) AS [Record Id],x.value(‘(//Record/@type)[1]‘, ‘varchar(30)‘) AS [Type],x.value(‘(//Record/@time)[1]‘, ‘bigint‘) AS [Record Time]FROM (SELECT CAST (record as xml) FROM sys.dm_os_ring_buffersWHERE ring_buffer_type = ‘RING_BUFFER_SECURITY_ERROR‘) AS R(x)) aCROSS JOIN sys.dm_os_sys_info sysORDER BY a.[Record Time] ASC
對於SQL Server 2008:
SELECT CONVERT (varchar(30), GETDATE(), 121) as runtime,dateadd (ms, (a.[Record Time] - sys.ms_ticks), GETDATE()) as [Notification_Time],a.* , sys.ms_ticks AS [Current Time]FROM(SELECTx.value(‘(//Record/Error/ErrorCode)[1]‘, ‘varchar(30)‘) AS [ErrorCode],x.value(‘(//Record/Error/CallingAPIName)[1]‘, ‘varchar(255)‘) AS [CallingAPIName],x.value(‘(//Record/Error/APIName)[1]‘, ‘varchar(255)‘) AS [APIName],x.value(‘(//Record/Error/SPID)[1]‘, ‘int‘) AS [SPID],x.value(‘(//Record/@id)[1]‘, ‘bigint‘) AS [Record Id],x.value(‘(//Record/@type)[1]‘, ‘varchar(30)‘) AS [Type],x.value(‘(//Record/@time)[1]‘, ‘bigint‘) AS [Record Time]FROM (SELECT CAST (record as xml) FROM sys.dm_os_ring_buffersWHERE ring_buffer_type = ‘RING_BUFFER_SECURITY_ERROR‘) AS R(x)) aCROSS JOIN sys.dm_os_sys_info sysORDER BY a.[Record Time] ASC
本文出自 “滴水石穿” 部落格,請務必保留此出處http://ultrasql.blog.51cto.com/9591438/1584055
SQL Server 環形緩衝區(Ring Buffer) -- RING_BUFFER_SECURITY_ERROR 診斷安全相