Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top