简体   繁体   English

如何在C ++ Win32 API中使用pwdlastset值和maxpwdage值获取pwdexpirydate?

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

i get the maxpwdage value and pwdlastset value using ADSI.. 我使用ADSI获得maxpwdage值和pwdlastset值。

Now i want to check the password expiry date... 现在我想检查密码的有效期...

hr = pDomain->get_MaxPasswordAge(&ret);

maxpwdage gives 432000... maxpwdage给出432000 ...

hr = pUser->get_PasswordLastChanged(&expirationDate);

pwdlastset gives 41176.470196759263... pwdlastset给出41176.470196759263 ...

how to achieve the password expiry date using this value? 如何使用此值来达到密码的有效期?

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. 您需要将MaxPasswordAge添加到PasswordLastChanged。

VARIANT date 变异日期

Type: DATE 类型: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. 日期以双精度数字表示,其中1900年1月1日午夜为2.0,1900年1月2日为3.0,依此类推。

  • The date can be converted to and from an MS-DOS representation using VariantTimeToDosDateTime. 可以使用VariantTimeToDosDateTime与MS-DOS表示形式进行日期转换。

So this means that 1.0 represent one day. 因此,这意味着1.0代表一天。

from WTypes.h : 从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 86400 = 24 * 60 * 60 =秒/天

Then use VariantTimeToDosDateTime to get human readable date. 然后使用VariantTimeToDosDateTime获取人类可读的日期。

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

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