Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to programatically lock a SQL Server Login. The goal is to emulate the automatic function in SQL That will lock out a user that makes several connection attempts with a bad password.

I can easily unlock a login, but I need to lock it as well.

I have tried looping through 20 times with a sqlConnection that contained an invalid password and I get very inconsistent results.

share|improve this question
Does this help?… – Aaron Copley Jul 2 '12 at 20:30

How about just scripting our a sqlcmd request?

Seems like you could easily create a script that calls some resource on the server very quickly and very often to do this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.