Easy points.......maybe: Trigger to prevent logon to a DB

  • OK, I know about this: http://www.sqlservercentral.com/scripts/Security/69558/

    But the script has "ALL SERVER".

    What I want is a trigger that is specific to my DB called "JunkStuff". I only want to block a servername from connect to my super dooper DB "JunkStuff".

    😀

    Thanks

  • Hmmm...

    Will this work????

    CREATE TRIGGER [connection_trigger]

    ON ALL SERVER WITH EXECUTE AS '...'

    FOR LOGON

    AS

    BEGIN

    IF EXISTS = (SELECT ORIGINAL_LOGIN_NAME FROM sys.dm_exec_sessions WHERE database_id = 11 AND ORIGINAL_LOGIN_NAME = 'mydomain\prefix-MV-purpose$')

    ROLLBACK;

    END;

    GO

    ENABLE TRIGGER [connection_trigger] ON ALL SERVER

    GO

    Haven't tried it yet. I think it's a winner though....lol:hehe:

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply