开发者

Timespan since last password reset

开发者 https://www.devze.com 2023-02-08 03:26 出处:网络
I have created a small asp.net application that allows users to reset their passwords. I am able to retrieve that last time the password was reset from the Directory Searcher object, but I\'m havin开发

I have created a small asp.net application that allows users to reset their passwords. I am able to retrieve that last time the password was reset from the Directory Searcher object, but I'm havin开发者_运维问答g trouble with checking the timespan since the last password reset. The users can reset their passwords again after 24 hours have passed, otherwise they well get an error stating that they are not able to update their password at this time. Any recommendations on how to best go about doing this?

string passwordLastSet = string.Empty;
passwordLastSet = DateTime.FromFileTime((Int64)(result.Properties["PwdLastSet"][0])).ToString();

Thanks,

Jason


You need to subtract it from either DateTime.Now or DateTime.UTC now, depending on whether your other date is UTC or local. If the DateTime kinds are different it won't show an error, but silently give the wrong result.

0

精彩评论

暂无评论...
验证码 换一张
取 消