Monitoring Suspicious System Time Change  
Author Message
Deus23





PostPosted: Visual C# General, Monitoring Suspicious System Time Change Top

I'm at a lot as what to search for but heres my problem.

The current application I am writing depends heavily on specified dates. The program will compensate for any computations it may have missed since it was last ran. So the program doesn't have to run continuously.

Each time the main loop executes I store a LastTick DateTime into a database. So if the System Date is set back I can catch this. But is there a way to tell if the system clock was purposely pushed forward w/out quering a web service

The problem arises if a user pushes his clock forward by accident or on purpose and runs the application (or if the application is already running). The app will think that it just hasn't ran in X days since lasttick and compute and store various transactions.

So whats the best solution for this
* Would it be maybe prompting the user if we havn't ran in X days if he want to continue
* Just offer database rollback to certain dates
* Attempt to monitor system time

I am guessing the most efficient way is to offer a rollback if the user notices that he accidently ran the app after he push the clock forward

Thanks in advance.


Visual C#4  
 
 
timvw





PostPosted: Visual C# General, Monitoring Suspicious System Time Change Top

Your program could talk to an ntp server (or something else that reliably returns the time) instead of relying on the system time...


 
 
ahmedilyas





PostPosted: Visual C# General, Monitoring Suspicious System Time Change Top

true but it would be more expensive - hooking up to the service all the time and checking the time. What happens if the site goes down or the network connection

 
 
Peter Ritchie





PostPosted: Visual C# General, Monitoring Suspicious System Time Change Top

There's really not much you can do about something like this. If you're using a remote database (say SQL Server) then you could use the date/time information from that server instead. Alternatively, as has been suggested you'll have to use some other server for your date/time information and ignore the client computer's date/time. Otherewise, you'll just have accept what the local user has done with their local settings.

 
 
Deus23





PostPosted: Visual C# General, Monitoring Suspicious System Time Change Top

Thank you for all your thoughts.

I am using SQLite as the database so I won't be relying on a remote server.

I have decided to prompt the user if we havn't ran in X days.
This way the user if he set his clock forward for unknown reasons will be able to exit the app or proceed to read-only mode.

... and as far pushing back the clock they can exit or rollback