As following to my local security policy, I have to establish the limit appropriate to the type of user account accessing the SQL Server instance on SQL Server 2014 Enterprise.
I think login trigger is the one for this set up as following to the Microsoft aritcle below.
Logon Trigger
Can I confirm few thing on the trigger?
(1) Is this query correct to set up to existed SQL login account called "General_User" allowed 5 session maximum? (The "General_User" is already existed.) I am not sure what does the "ALL SERVER WITH EXECUTE AS" part is.
USE master;
CREATE TRIGGER Limit_Connection_For_General_User
ON ALL SERVER WITH EXECUTE AS 'General_User'
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN()= 'General_User' AND
(SELECT COUNT(*) FROM sys.dm_exec_sessions
WHERE is_user_process = 1 AND
original_login_name = 'General_User') > 6
ROLLBACK;
END;
(2) After creating trigger as above, it will be showed up under (Instance Name)/Security/Server Objects/ Triggers on Management Studio?
(3) This is my test plan to confirm if the trigger work correctly. Is this right way to confirm the trigger?
-Open Mangement Studio and connect to the instance continuously.
-If the trigger is works fine, The 6th time connection will be error.
-Confirm to the error is automatically logged on event log under Event viewer/Windows Logs/Application.
(4) If I create the trigger on the (1), is it listed up in the result of below query?
SELECT * FROM master.sys.server_triggers;