Hi Every one,
I have developed a windows application in which i am capturing the windows events like lock,unlock, logon,disconnect etc.
I have written the following code in windows service for capturing the events as they occured.
protected override void OnSessionChange(SessionChangeDescription changeDescription)
{
string pcName = Environment.MachineName.ToUpper();
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "MMM dd yyyy";
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern = "hh:mm:ss tt";
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator = "/";
switch (changeDescription.Reason)
{
case SessionChangeReason.SessionLock:
Idlog("4800");
Eventlogs(pcName, "4800", "System locked", DateTime.Now);
break;
case SessionChangeReason.SessionLogoff:
Eventlogs(pcName, "4647", "System logoff", DateTime.Now);
break;
case SessionChangeReason.SessionLogon:
Idlog("4624");
Eventlogs(pcName, "4624", "System logon", DateTime.Now);
break;
case SessionChangeReason.SessionUnlock:
Idlog("4801");
Eventlogs(pcName, "4801", "System Unlocked", DateTime.Now);
break;
case SessionChangeReason.RemoteDisconnect:
Eventlogs(pcName, "4779", "Session disconnected", DateTime.Now);
break;
case SessionChangeReason.RemoteConnect:
Idlog("4778");
Eventlogs(pcName, "4778", "Session reconnected", DateTime.Now);
break;
case SessionChangeReason.ConsoleConnect:
Idlog("4778");
Eventlogs(pcName, "4778", "Session c reconnected", DateTime.Now);
break;
case SessionChangeReason.ConsoleDisconnect:
Eventlogs(pcName, "4779", "Session c disconnecetd", DateTime.Now);
break;
default:
break;
}
}
Quote:
Everything is working fine but the
SessionChangeReason.RemoteConnect and SessionChangeReason.RemoteDisconnect are being fired two times always when i perform Disconnect and Reconnect
and the order is as follows
Message
Session disconnected
Session reconnected
Session disconnected
Session reconnected
So for two events iam getting four results.
Can anybody please help me why this is happening?
Thanks in Advance
What I have tried:
Unable to find the root cause of this Event