Introduction
Introduction Statistics Contact Development Disclaimer Help
Return Create A Forum - Home
---------------------------------------------------------
ExcelSoft Database Professionals
https://esdbp.createaforum.com
---------------------------------------------------------
*****************************************************
Return to: Scripts
*****************************************************
#Post#: 116--------------------------------------------------
Limit user login time connection during business hours for a us
er
By: srinivasma_exceldbp Date: December 16, 2014, 9:44 pm
---------------------------------------------------------
/*
Limit user login time connection during business hours for a
user(example: testuser1)
ie �between 10:00 and 18:00 hours
*/
USE [master]
GO
--Create the login on your servel called "testuser1"
CREATE LOGIN [testuser1] WITH PASSWORD=N'StrongPassword'
,DEFAULT_DATABASE=[master]
,DEFAULT_LANGUAGE=[us_english]
,CHECK_EXPIRATION=OFF
,CHECK_POLICY=OFF
GO
USE [master]
GO
CREATE TRIGGER [connection_limit_trigger]
ON ALL SERVER
FOR LOGON
AS
BEGIN
DECLARE @ErrorText [varchar](128)
SET @ErrorText = 'Cannot allow login to "testuser1" outside of
normal business hours. '
SET @ErrorText = @ErrorText + 'Please try again between business
hours 10:00 and 18:00.'
IF ORIGINAL_LOGIN() = 'testuser1' AND
(DATEPART(HOUR, GETDATE()) < 10 OR DATEPART (HOUR,
GETDATE()) > 18)
BEGIN
PRINT @ErrorText
ROLLBACK;
END
END;
GO
ENABLE TRIGGER [connection_limit_trigger] ON ALL SERVER
GO
execute as login = 'testuser1'
*****************************************************
You are viewing proxied material from gopher.createaforum.com. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.