Check last three passwords
Posted on 2014-04-17
I have a security log that I store (encrypted) the passwords used to log in.
When users are required to change their password every three months they cannot use one of the previous three, and I'm having trouble writing that query...
Best I could come up with was getting the third top date and then search within that time frame, but is there a better way? Not sure how to structure that together in one line which is what I'd really like to do.
This would get me the three last used passwords, but I still need to test against the supplied one...
SELECT TOP 3 logdate, username, dbo.decrypt(password), logdate
WHERE username = 'testuser' AND Success = True
ORDER BY logdate desc
Hope this makes sense :)