Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Server 2012 Concurrent Sessions

Posted on 2014-03-27
5
Medium Priority
?
400 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

604 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