我是否可以在SQL Server 2008 R2中仅启用特定用户的TCP连接,或者在另一方面,是否可以阻止某些用户使用TCP远程连接到SQL Server?
答案 0 :(得分:1)
我会使用Logon Triggers功能来完成此任务。
答案 1 :(得分:1)
CREATE TRIGGER remote_connection_limit_trigger
ON ALL SERVER WITH EXECUTE AS 'sa'
FOR LOGON
AS
BEGIN
DECLARE @result XML
SET @result = EVENTDATA()
DECLARE @spid NVARCHAR(MAX)
SET @spid = @result.value('(/EVENT_INSTANCE/SPID)[1]', 'nvarchar(MAX)')
DECLARE @connectionType NVARCHAR(MAX)
SELECT @connectionType = net_transport FROM sys.dm_exec_connections WHERE session_id = @spid
IF @connectionType = 'TCP' AND ORIGINAL_LOGIN() <> 'temp_remote_user'
ROLLBACK;
END;