简体   繁体   English

确定订阅是否仍然有效而不与DateTime.Now进行比较

[英]Determine if subscription is still valid without comparing to DateTime.Now

This question may be easy and the answer obvious, but I can't seem to be able to find a solution right now. 这个问题可能很容易且答案很明显,但我现在似乎无法找到解决方案。 I built an application which has a big flaw in it. 我构建了一个有很大缺陷的应用程序。 In a property of my User class, I check to see if the user subscription is expired. 在我的User类的一个属性中,我检查用户订阅是否已过期。 To do this, I compare the ending date of the subscription with DateTime.Now: 为此,我将订阅的结束日期与DateTime.Now进行比较:

return (DateTime.Compare(DateTime.Now, subEndDate) > 0);

It doesn't take a genius user to realize that all it is needed is to change the Windows date to an earlier one, and then the application won't expire at all. 不需要天才的用户就能意识到,只需将Windows日期更改为更早的日期,然后该应用程序就不会过期。 So I think that comparing to DateTime.Now should not be done, is there a better method that I could use in order to validate a subscription date? 因此,我认为不应该与DateTime.Now进行比较,是否可以使用一种更好的方法来验证订阅日期?

Thanks. 谢谢。

Regards, 问候,

调用网络服务或检查数据库以确定订阅是否仍处于活动状态

也许您可以从客户端程序中提取订阅到期逻辑并将其放入外部服务,然后您的客户端应用程序可以连接到其他服务器并根据传入的用户参数检索到期详细信息?

Does this actually matter? 这真的重要吗? If your product is purely web based the only time you have to worry about is your server time. 如果您的产品是纯粹基于Web的,那么您唯一需要担心的就是服务器时间。 If the server time is able to be altered without your consent you probably have larger problems to worry about. 如果在未经您同意的情况下可以更改服务器时间,则可能要担心更大的问题。

If your product is desktop based, then how much protection do you want build in? 如果您的产品基于台式机,那么您希望内置多少保护? If you just want to protect against your casual user the solution you have is probably enough. 如果您只想保护您的临时用户,那么您拥有的解决方案可能就足够了。 If someone is determined to pirate your software then they will probably be successful. 如果确定有人盗版您的软件,那么他们可能会成功。 If you want to make it harder for these users one solution would be to keep a log of all the times the application has been run. 如果您想让这些用户更难,一种解决方案是保留运行该应用程序的所有时间的日志。 This way you can get an idea of they are playing with the clock. 通过这种方式,您可以了解他们正在玩时钟。

There are several NTP servers out there which you can use for free... they return the exact time and your casual user won't have a hand in manipulating those... to access them you have several options - though none built-in: 有几台NTP服务器可供您免费使用...它们返回准确的时间,您的临时用户将无权操纵这些服务器...要访问它们,您有多种选择-尽管没有内置的:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM