Generating alert from Failed login attempt

  • I'm trying to set up a SQL Alert to run when a Failed login error is generated. For whatever reason, I can't seem to get this working. I have it set up to run on error 18456 (Failed login), I have the server set to log failed login attempts and I can see the entry in the log file, but the alert never occurs. Basically, I want a way to detect when someone is trying to hack into my database using a brute force approach. Any ideas?

  • did you stop/start sqlagent ? (is needed when you activate the first alert)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Also you need to stop and restart sql server after changing the audit status.

    The alert works fine for me (scripted below, excluding notifications).

    IF (SELECT COUNT(*) FROM msdb.dbo.sysalerts WHERE name = N'Alert 18456 Login failed for user') < 1

    BEGIN

    EXECUTE msdb.dbo.sp_add_alert @name = N'Alert 18456 Login failed for user', @message_id = 18456, @severity = 0, @enabled = 1, @delay_between_responses = 60, @include_event_description_in = 5, @category_name = N'[Uncategorized]'

    END

    Steven

  • Along those same lines, are any of your alerts firing?

    K. Brian Kelley

    http://www.truthsolutions.com/

    Author: Start to Finish Guide to SQL Server Performance Monitoring

    http://www.netimpress.com/

    K. Brian Kelley
    @kbriankelley

  • The script that steven sent worked. Thanks for all your help. I'm not sure what I was doing wrong, but it appears to be firing now.

  • how can i modify this by saying that it would shoot an email only if somebody tries to login more then 3x .

    Thanks

  • There's no logic in SQL Server for this. You'd need something to scan the SQL log and send you an alert. However, you'll need to define this. Do you mean 3 failed logins in a few minutes? In a day? Ever? The same user? Any user?

    This isn't a simple thing. Is this SQL 2000?

  • Yes three failed logins in 5 min . Its sql server 2012

  • Moving to the SQL 2012 forum. This was posted in SQL 2000.

    In 2012, you might be able to do something with xEvents and a trigger when you get xx logins in xx time from a user. I'd think a Window function would help here. I don't have time to run a test, but this might help:

    https://www.mssqltips.com/sqlservertip/3214/use-extended-events-to-get-more-information-about-failed-sql-server-login-attempts/

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply