Solved

SQL Server 2012 Concurrent Sessions

Posted on 2014-03-27
5
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

717 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