Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
?-- =============================================
-- Description: Deactivates users that have not logged into the Module in over defined number of days
--
-- Maintenance Log:
--
-- Update By Update Date Description
-- Josh --------- ----------------------------
-- =============================================
CREATE PROCEDURE seclyr.[uspDoDeactivateInactiveUsers]
AS
BEGIN
DECLARE @numDays int;
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
BEGIN TRY
SET @numDays = 90;
UPDATE seclyr.Users SET
Inactive = 1
, DateInactive = GETDATE()
FROM seclyr.Users
INNER JOIN seclyr.UserRoles
ON seclyr.Users.UserID = seclyr.UserRoles.UserID
WHERE DATEDIFF(dd, seclyr.Users.DateLastLogin, GETDATE()) > @numDays
AND seclyr.UserRoles.AccessStatus = 'Approved';
END TRY
BEGIN CATCH
PRINT 'There was an error deactivating inactive users' + CHAR(13);
SELECT * FROM dbo.ufnGetErrorInfo();
EXEC uspRaiseErrorInfo;
END CATCH
END