Sql Trigger İle İp Engelleme

USE [master]

GO

 

/****** Object:  DdlTrigger [connection_AUDIT]    Script Date: 22.12.2021 17:04:10 ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

CREATE TRIGGER [connection_AUDIT]

ON ALL SERVER

FOR LOGON

AS

BEGIN

    DECLARE @CLIENT_NET_ADRES VARCHAR(100);

    SELECT @CLIENT_NET_ADRES = client_net_address

    FROM sys.sysprocesses AS S

        INNER JOIN sys.dm_exec_connections AS decc

            ON S.spid = decc.session_id

    WHERE spid = @@SPID;

    IF @CLIENT_NET_ADRES <> ''

    BEGIN

        DECLARE @ENGELLENSIN CHAR(1);

        SET @ENGELLENSIN = 'E';

        IF SUBSTRING(@CLIENT_NET_ADRES, 1, 1) NOT IN ( '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' )

        BEGIN

            SET @ENGELLENSIN = 'H';

        END;

        IF CHARINDEX('192.168.', @CLIENT_NET_ADRES) = 1

        BEGIN

            SET @ENGELLENSIN = 'H';

        END;

        IF CHARINDEX('10.0.', @CLIENT_NET_ADRES) = 1

        BEGIN

            SET @ENGELLENSIN = 'H';

        END;

                               IF @CLIENT_NET_ADRES = '46.1.214.162'

        BEGIN

            SET @ENGELLENSIN = 'H';

        END;

        IF @ENGELLENSIN = 'E'

        BEGIN

            ROLLBACK;

        END;

    END;

END;

GO

Bu makaleyi yararlı buldunuz mu?