Auto Disable a SQL Server User

Posted on

Question :

I have a SQL Authentication User: JOHNDOE

I would like this account to auto-expire or auto-disable after X days or at a certain date/time. Any suggestions or best practices to do this?

Answer :

You could setup a job that reads from a table containing a list of logins and their expiration dates. For every login that is expired in this table it could just drop it. There you could also automatically deal with users associated with and databases own by this login.

There’s no native way to do this. You’ll have to create a SQL Agent job which disabled the login and the specific time.

Leave a Reply

Your email address will not be published. Required fields are marked *