Solved

SQL Server 2012 Concurrent Sessions

Posted on 2014-03-27
5
378 Views
Last Modified: 2014-04-08
I need help in implementing the following:

Implement logon triggers to restrict users from logging on multiple times.
0
Comment
Question by:jasonhdz
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39960541
You do realize that there is a perfectly good example in SQL Server BOL for CREATE TRIGGER (Transact-SQL), right?  Look for Example F
0
 
LVL 1

Author Comment

by:jasonhdz
ID: 39960545
No i did not, that is why i asked.  But thanks!  I will check it out!
0
 
LVL 1

Author Comment

by:jasonhdz
ID: 39960554
USE master;
GO
CREATE TRIGGER connection_limit_trigger
ON ALL SERVER WITH EXECUTE AS "JAY-PC\testdba1"
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN()= "JAY-PC\testdba1" AND
    (SELECT COUNT(*) FROM sys.dm_exec_sessions
            WHERE is_user_process = 1 AND
                original_login_name = "JAY-PC\testdba1") > 3
    ROLLBACK;
END;
0
 
LVL 1

Author Comment

by:jasonhdz
ID: 39960555
from the scrip above, i have the following issues:

1.  It looks like the If is looking for a specific user, i need to implement this for every single user login in the db server.
2.  Only Windows Login is implemented.  It does not appear to recognize the Windows User Identificator
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 39960705
See if this works for you (but be careful and don't lock yourself out):
USE master;
GO
CREATE TRIGGER connection_limit_trigger ON ALL SERVER
    FOR LOGON
AS
    BEGIN
        IF (SELECT  COUNT(*)
            FROM    sys.dm_exec_sessions
            WHERE   is_user_process = 1
                    AND original_login_name = ORIGINAL_LOGIN()
           ) > 3
            ROLLBACK;
    END;

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html) provided 218 attendees with a step-by-step guide for identifying Acti…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question