达到特定阈值后如何执行触发器?

发布于 2024-09-14 17:12:48 字数 177 浏览 1 评论 0原文

我有一个网络应用程序,它将无效的登录尝试记录到数据库表中。

有没有一种方法可以在表上创建一个触发器,该触发器仅在过去几个小时左右创建一定数量的记录后运行,缺少诸如 if count(*) > > 之类的东西? 100 ?

最终目标是在登录尝试失败次数异常时发送电子邮件。

I have a web app that logs invalid login attempts to a database table.

Is there a way to create a trigger on the table that only runs after a certain number of records have been created in the last hours or so, short of something like if count(*) > 100?

The end goal is to send an email if there are an abnormal number of failed login attempts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

北斗星光 2024-09-21 17:12:48

为什么要有触发器?创建每 n 分钟运行一次的 SQL 代理作业。您检查在过去一小时内是否有超过 100 次无效登录尝试,如果是这样,请运行包含详细信息的数据库邮件过程,请查找 sp_send_dbmail

Why a trigger? create a SQL agent jobs that runs every n minutes. You check if in the last hour there where more than 100 invalid login attempts, if this is true run a database mail proc with the details, look up sp_send_dbmail

哽咽笑 2024-09-21 17:12:48

创建一个针对每种情况运行的触发器,并让它查看是否满足进一步操作的标准。如果不希望继续执行操作(例如,对于过去一小时内的尝试 102),您可以在另一个表中记录上次执行此类操作的时间,然后制定其必须 > 的标准。每小时 100 次失败尝试,并且距上次此类操作必须已过去一小时。

Create a trigger that runs for every case, and have it see if the criteria for further action are met. If continuing actions aren't desired (e.g. for attempt 102 in the past hour) you could record the time it last took such action in another table, then make the criteria that it must be > 100 failed attempts per hour AND it must be an hour since the last such action.

请持续率性 2024-09-21 17:12:48

不要使用触发器来执行此操作。创建一个作业来监控过去一小时内登录失败的计数,并在超过特定阈值时发送电子邮件。让它每小时运行一次。

Don't do this with a trigger. Create a job to monitor the count of failed logins in the last hour and send an email if it is over a certain threshold. Have it run hourly.

新雨望断虹 2024-09-21 17:12:48

你不能。最好的选择是将检查放在触发器本身内部。

You can't. The best option is to put the check inside the trigger itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文