SHARE
TWEET

Untitled

SQLSoldier Jul 16th, 2013 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TRIGGER ltAdminsOnly
  2. ON ALL SERVER WITH EXECUTE AS N'sa'
  3. FOR LOGON
  4. AS
  5. BEGIN
  6.         Declare @IsAdmin int;
  7.         Exec As login = ORIGINAL_LOGIN();
  8.         Select @IsAdmin = ISNULL(IS_MEMBER('Domain\AdminGroup'), 0);
  9.         Revert;
  10.  
  11.         If HOST_NAME() <> @@SERVERNAME
  12.                 And HOST_NAME() <> SERVERPROPERTY('ComputerNamePhysicalNetBios')
  13.                 And @IsAdmin = 0
  14.           Begin;
  15.                 ROLLBACK;
  16.           End;
  17. END;
RAW Paste Data
Top