﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Gregory Ferdinandsen  / SQL Server Access Restriction / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 01:24:40 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>any one plz help on this</description><pubDate>Mon, 06 Dec 2010 08:19:52 GMT</pubDate><dc:creator>atul.verma.ietk</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>Hi,while using this script I had created sql_audit database but not able to create trigger getting following error while running provided scripMsg 156, Level 15, State 1, Procedure trg_LoginBlackList, Line 5Incorrect syntax near the keyword 'as'.Msg 1088, Level 16, State 119, Line 2Cannot find the object "trg_LoginBlackList" because it does not exist or you do not have permissions.Please revert ..........</description><pubDate>Fri, 03 Dec 2010 07:06:51 GMT</pubDate><dc:creator>atul.verma.ietk</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>[quote][b]srinivasreddy4uhyd (3/11/2010)[/b][hr]Thanks a lot Greg. This script is really helpful.Correct me If I am wrong. My situation is I want to restrict group of accounts which can login from some applications but not from SSMS / Excel / DBArtisan / .....As suggested by you the sql service account can be added to the  [BlackList] with [RestrictionEnabled] to zero to avoid rollback right ?Please Advise.Thanks &amp; Regards,Srini[/quote]Section #6 of the Trigger covers this scenario:    --#6    --If a particular application connects to SQL Server, with a given UserName (i.e. service account cannot connect with SSMS)    If(Exists(Select * from SQL_Audit.dbo.BlackList where AppName = @AppName and LoginName = @User and RestrictionEnabled = 1))To set it up, insert to the blacklist tableUser and applicationEach user and application requires a seperate entry, i.e.user1, Exceluser1, Accessuser1, Toaduser2, Exceluser2, Accessuser2, ToadSo update the table with each developer login and the application that cannot be used.  Alternatively, you could add a condition at the begining of the trigger:If ((@User in ('User1', User2', 'User3')) and (@AppName in ('Excel', Access', 'TOAD')))Begin  Rollback    insert into SQL_Audit..Violations                (PostDate, LoginName, IPAddress, HostName, ServerName, AppName, ViolationType)                values (@PostTime, @User, @IPAddress, @HostName, @SrvName, @AppName, 'ApplicationName')  Return;EndThe advantage of the second method is that the hardcoded values require less disk IO to process; however, the disadvantage is that the SP would have to be recreated to every change in Users and apps.</description><pubDate>Thu, 11 Mar 2010 15:59:22 GMT</pubDate><dc:creator>GregoryF</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>Thanks a lot Greg. This script is really helpful.Correct me If I am wrong. My situation is I want to restrict group of accounts which can login from some applications but not from SSMS / Excel / DBArtisan / .....As suggested by you the sql service account can be added to the  [BlackList] with [RestrictionEnabled] to zero to avoid rollback right ?Please Advise.Thanks &amp; Regards,Srini</description><pubDate>Thu, 11 Mar 2010 13:20:56 GMT</pubDate><dc:creator>srinivasreddy4uhyd</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>Really, really, really good!Thanks Greg.</description><pubDate>Wed, 03 Mar 2010 08:00:06 GMT</pubDate><dc:creator>Tom Garth</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>As for scaling, I am not sure how well it would handle thousands of logins per second.  My best advice would be to add at the begining of the trigger a exit clause that covers 90% of the cases, i.e. 1) the sql server service account logging from the local server2) the application service service account where HostName in (list of app servers)3) and/or ApplicationName = '&amp;lt;Application Name&amp;gt;'4) any member of the sa role (perhaps hardcoding the members of your dba team)</description><pubDate>Wed, 03 Mar 2010 07:37:02 GMT</pubDate><dc:creator>GregoryF</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>How well does this scale? If I have thousands of users hitting the server...If I'm right, the scale issue will very often not be picked up during testing but only appear when it is released to the production environment.</description><pubDate>Wed, 03 Mar 2010 01:47:14 GMT</pubDate><dc:creator>ianT</dc:creator></item><item><title>RE: SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>Thanks for this. I really learnt something new here.BTW, I love the URLs in the comments (do the same thing myself) as it is a great way to document something which is really documented elsewhere.</description><pubDate>Wed, 03 Mar 2010 01:21:51 GMT</pubDate><dc:creator>Gary Varga</dc:creator></item><item><title>SQL Server Access Restriction</title><link>http://www.sqlservercentral.com/Forums/Topic864550-2621-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Security/69558/"&gt;SQL Server Access Restriction&lt;/A&gt;[/B]</description><pubDate>Fri, 12 Feb 2010 05:32:51 GMT</pubDate><dc:creator>GregoryF</dc:creator></item></channel></rss>