我正在尝试获取人们尝试登录我们服务器的事件列表,并禁止在x
尝试失败后立即阻止ip。
这是我到目前为止所做的:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
EventLog eventLog;
eventLog = new EventLog();
eventLog.Log = "Security";;
eventLog.Source = "Security-Auditing";
eventLog.MachineName = "TGSERVER";
var count = 0;
foreach (EventLogEntry log in eventLog.Entries)
{
if (count > 200)
{
return;
}
Console.Write("eventLog.Log: {0}", eventLog.Log);
count++;
}
}
不多,但这是一个开始。
我的问题是,我似乎无法隔离这些特定事件,因为我无法按eventid
或keyword
进行过滤,或者至少我看不到任何方法。
我的目标是获取那些不良尝试的IP。
有人有任何建议吗?
答案 0 :(得分:2)
EventLogEntry
包含EventID
属性。但要小心,因为EventID
现在已经成功了。请阅读EventID description中的备注部分。据我所知,EventID显示在windows eventviewer(eventvwr.msc)中,但在事件日志文件(.evtx)中,事件与InstanceId
一起存储。