Hello, I am programming in C # and I have a service that starts with Windows and I need to know how to perform an action when I detect it when a user logs incorrectly when logging in. Windows
Hello, I am programming in C # and I have a service that starts with Windows and I need to know how to perform an action when I detect it when a user logs incorrectly when logging in. Windows
You could use the events of the class
to detect when it authenticates in windows, although I do not see that there is an incorrect login event specifically
But you could evaluate using the events of WMI
by means of Win32_LogonSession
and
as it is proposed here
Get notified from logon and logoff
private readonly static WqlEventQuery query = new WqlEventQuery("__InstanceCreationEvent", new TimeSpan(0, 0, 1), "TargetInstance ISA \"Win32_LogonSession\"");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
watcher.EventArrived += new EventArrivedEventHandler(HandleEvent);
watcher.Start();
assigning the handler that triggers when a wmi event occurs
private void HandleEvent(object sender, EventArrivedEventArgs e)
{
ManagementBaseObject f = (ManagementBaseObject)e.NewEvent["TargetInstance"];
//resto codigo
}