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,
JasonYou 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.
精彩评论