how to get pwdexpirydate using pwdlastset value and maxpwdage value in C++ win32 API?

放肆的年华 提交于 2019-12-11 18:15:17

问题


i get the maxpwdage value and pwdlastset value using ADSI..

Now i want to check the password expiry date...

hr = pDomain->get_MaxPasswordAge(&ret);

maxpwdage gives 432000...

hr = pUser->get_PasswordLastChanged(&expirationDate);

pwdlastset gives 41176.470196759263...

how to achieve the password expiry date using this value?


回答1:


MaxPasswordAge

  • Indicates the maximum time interval, in seconds, after which the password must be changed by the user.

PasswordLastChanged

  • The last time the password was changed.

You need to add MaxPasswordAge to PasswordLastChanged.

VARIANT date

Type: DATE

  • A date and time value. Dates are represented as double-precision numbers, where midnight, January 1, 1900 is 2.0, January 2, 1900 is 3.0, and so on.

  • The date can be converted to and from an MS-DOS representation using VariantTimeToDosDateTime.

So this means that 1.0 represent one day.

from WTypes.h :

typedef double DATE;

So:

DATE expirationDate;
VARIANT vtExpDate;

expirationDate += (double)(ret / 86400);

vtExpDate.vt = VT_DATE ;
vtExpDate.date = date ;

86400 = 24 * 60 * 60 = seconds/day

Then use VariantTimeToDosDateTime to get human readable date.



来源:https://stackoverflow.com/questions/13135747/how-to-get-pwdexpirydate-using-pwdlastset-value-and-maxpwdage-value-in-c-win32

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!