LogOn Triggers. - limiting sessions anything you want regarding logon .. with this you can limit sessions

 select is_user_process,original_login_name, * from sys.dm_exec_sessions


Create trigger tr_limitlogin

on all server

for logon 

as  


Begin

          Declare @LoginNmae nvarchar(100)

  Set @LoginNmae= ORIGINAL_LOGIN() -- this function will return us the login that is trying to make a connection 


  IF(Select Count(*) from sys.dm_exec_sessions

  where is_user_process=1 and original_login_name=@LoginNmae)>3  -- one is object explorer of sql server and another 2 you can open

  Begin

  Print ('Fourth Connection attempt by' + @LoginNmae + 'blocked')

   RollBack;

   End

End


execute sp_readerrorlog //error log thrown by logon trigger is recorded in this system stored procedure


--Idea : for making trial version of 3 days we can use this with this view sys.dm_exec_sessions and calculate date .. and just roll back -- just idea .. that poped up .. we can do anything with this





Comments