Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
现需要限制MsSql上的登录IP,错误的直接将以下语句执行,而没有改192.168.1.1,此时连接服务器就再也连接不上,需要用DAC解决
注:限制IP访问最好用IPsec策略做,以免影响性能。
1,失误代码
USE master
GO
CREATE TRIGGER tr_LoginCheck
ON ALL SERVER
FOR LOGON
AS
DECLARE @ClientHost varchar(100)
SET @ClientHost= EVENTDATA().value(‘(/EVENT_INSTANCE/ClientHost)[1]‘, ‘varchar(15)’)
IF ClientHost <>’127.0.0.1′ AND ClientHost <> ‘<local machine>’
ROLLBACK TRAN
GO
–此触发器可在[服务器对象 – 触发器下]查看
可能要给账号开权限
USE [master]
GO
CREATE USER [myuser] FOR LOGIN [myuser]
GO
–grant select on ipcheck to myuser
grant VIEW SERVER STATE to myuser
2,失误后登录提示:login failed due to a TRIGGER
3,解决方案:
开始-运行-cmd: sqlcmd -S LocalHost -d master -A
1> DROP TRIGGER tr_LoginCheck ON ALL SERVER
2> GO