Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

How do I limit user access to certain time of day Expand / Collapse
Author
Message
Posted Thursday, July 24, 2008 9:38 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 12, 2014 2:58 PM
Points: 92, Visits: 170
We have a group of queries that we want to limit to run off peak hours to stop from bogging down production.
These queries pull data from our prod server and store the results on a reporting server.
We don't want the developers to run the queries during prime time
Our test server is an extremely small subset of the production data so to get a real idea of how long a query will run it needs to be run against prod - but off hours.
Is there any way to limit user access to the server to only certain times of day?
I was thinking that one way would be to limit their access to views that had code in it to check the time of day and return an error if during prime time, but that would have to be added to every view.
Post #540295
Posted Thursday, July 24, 2008 1:47 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 20, 2012 2:13 PM
Points: 38, Visits: 219
I'm no network guy, but if you are running NT authentication for db access can't the users (user group) at the NT level be granted access to a particular server on a time basis?
Post #540510
Posted Thursday, July 24, 2008 2:04 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 12, 2014 2:58 PM
Points: 92, Visits: 170
I'm not a network guy either so I was hoping someone else would know if it could be done and if so how to do it.
I know net nanny can do it! :D
Post #540526
Posted Thursday, July 24, 2008 2:08 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 20, 2012 2:13 PM
Points: 38, Visits: 219
So if you use Net Nanny, and have a server job that adds pr0n at 8 am, then removes it at 5 pm .....


Post #540528
Posted Thursday, July 24, 2008 3:29 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, April 2, 2014 2:01 PM
Points: 659, Visits: 6,104
How about this...
put the queries you want executed in the after house window inside a procedure or procdures. Create a user with explicit permissions to execute them. Deny execute to your DBA/users. Then schedule the procs in a job.

DAB
Post #540582
Posted Thursday, July 24, 2008 5:43 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, June 6, 2009 11:47 PM
Points: 48, Visits: 52
Depending on the version of the SQL Server you are using you could use a DDL Trigger for Logon access. You can have full control on who/what/when/where. You will need SQL Server 2005 (SP2 I believe). Here is a good link about this technique:

http://blogs.technet.com/vipulshah/archive/2007/12/04/ddl-triggers-and-logon-triggers.aspx

Thanks


Herve Roggero
hroggero@pynlogic.com
MCDBA, MCSE, MCSD
SQL Server Database Proxy/Firewall and Auditing
Post #540623
Posted Monday, July 28, 2008 7:46 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 12, 2014 2:58 PM
Points: 92, Visits: 170
I am running SQL 2005 so the LOGON Triggers, DDL Triggers looks like just the ticket.
I'll have to experiment on a test server to see how they operate but from what I read on that link it looks like exactly what I wanted.
Thanks!
Post #541904
Posted Monday, July 28, 2008 10:43 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 12, 2014 2:58 PM
Points: 92, Visits: 170
I set up a user id called 'batchid' on a test server and created a logon trigger like this:
CREATE TRIGGER usrLoginCheck_LogonTrigger
ON ALL SERVER WITH EXECUTE AS 'batchid'
FOR LOGON
AS
BEGIN
declare @EarlyTime datetime,
@LateTime datetime,
@todays_date varchar(25)

set @todays_date = CONVERT(varCHAR(25),GETDATE(),110)
set @EarlyTime = Convert(datetime, @todays_date + ' 07:00:00.000')
set @LateTime = Convert(datetime, @todays_date + ' 23:00:00.000')
if ORIGINAL_LOGIN()= 'batchid'
and getdate() between @EarlyTime and @LateTime
ROLLBACK;
END

I tried to run an osql session to run a query from my desktop and it errored like I expected:
Logon failed for login 'batchid' due to trigger execution.
then I altered the trigger so the early time was after the current time (i.e. I was in the batch window and not during prime time) and the trigger allowed me to run the query.
Post #542044
Posted Monday, July 28, 2008 10:48 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, May 30, 2014 6:27 PM
Points: 2,808, Visits: 7,175
I havent tried this before,

but have you thought about creating a job that runs each night and changes the permissions for those users to DENY, and then run another job that gives them permission back in the morning.

Post #542050
Posted Tuesday, July 29, 2008 6:25 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 12, 2014 2:58 PM
Points: 92, Visits: 170
No I hadn't and for a sql 2000 instance that just may do the trick!
That's what I love about these forums - there are so many good ideas out there.
Post #542565
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse