We have a large number of accounts in our solarwinds system, a mixture of Ad grous and local accounts. To make sure we keep on top of the accounts we've set all accounts to disabled that haven't been logged into in the last year. To do this we run the following SQL against the DB weekly:
UPDATE Accounts
SET AccountEnabled = 'N'
WHERE
(
dbo.Accounts.LastLogin <= dateadd(
m,
datediff(m, 0, CURRENT_TIMESTAMP) -12,
0
)
OR dbo.Accounts.LastLogin >= dateadd(
m,
datediff(m, 0, CURRENT_TIMESTAMP)+ 1,
0
)
)
AND AllowAdmin = 'N'
AND AccountType != 4
AND AccountEnabled != 'N';