SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Server Trigger


Server Trigger

Author
Message
adb2303
adb2303
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2410 Visits: 3229
Hi,

We have a DDL trigger on our server preventing access from Microsoft Office, Excel or Access applications for unauthorised users. Users and their workstation details are in a 'white list', which gives them access if they've been approved. Every one else gets a 'login failed due to trigger execution' message.

I've just found out that when trying to create a DSN connection using the ODBC manager (SQL Server Native Client 10), it also fires the trigger. Is this a security feature to stop Office users using DSN connections as a backdoor, or is the ODBC manager seen as part of the office suite? Having said that, I've also tried using the ODBC manager from a machine without MS Office installed, and it still failed.

Login trigger code:


/****** Object: DdlTrigger [Logon_Trigger_Monitor_Excel] Script Date: 11/02/2011 09:01:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [Logon_Trigger_Monitor_Excel]
ON ALL SERVER WITH EXECUTE AS 'xxxx\xxxx'
FOR LOGON
AS
BEGIN
IF APP_NAME() LIKE '%MICROSOFT OFFICE%' OR APP_NAME() LIKE '%EXCEL%' OR APP_NAME() LIKE '%ACCESS%'
IF UPPER(ORIGINAL_LOGIN()) LIKE 'HERMES\%'
BEGIN
IF (SELECT COUNT(*)
FROM monitoring.dbo.tblExcelWhiteList
WHERE UPPER(loginwho) = UPPER(ORIGINAL_LOGIN())
AND UPPER(loginfrom) = UPPER(HOST_NAME())) = 0 ROLLBACK
END
END

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [Logon_Trigger_Monitor_Excel] ON ALL SERVER


adb2303
adb2303
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2410 Visits: 3229
Actually, just figured it out. SQL Server's picking up the connection as 'Microsoft Data Access Components'. Our login trigger's screening applications like '%ACCESS%'...

thanks for looking.. :-D
Gianluca Sartori
Gianluca Sartori
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23509 Visits: 13362
I ended up with a similar solution in the past because I had no other option.
However, be aware that this is not the best way to enforce security. Users should be unable to login because they don't have a login at all.

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
adb2303
adb2303
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2410 Visits: 3229
We allow users to access the database through the designated application, for which they are in an AD group with limited permissions, but we don't want those same users accessing the database from Excel, Access, etc. That's why it's set-up this way.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search