Help re. checking for password expiration/time comparisons
- From: ohaya <ohaya@xxxxxxx>
- Date: Thu, 31 Aug 2006 03:16:57 -0400
Hi,
I need to check whether a user's password in Active Directory is expired. I've used Sun's LDAP JDK to retrieve:
maxPwdAge = how long the passwords in AD are valid
lpwdLastSet = when the password was last reset
I have the following code so far:
GregorianCalendar Win32Epoch = new GregorianCalendar(1601,Calendar.JANUARY,1);
Date Win32EpochDate = Win32Epoch.getTime();
GregorianCalendar Today = new GregorianCalendar();
Date TodaysDate = Today.getTime();
long TimeSinceWin32Epoch = 10000 * (TodaysDate.getTime() - Win32EpochDate.getTime());
if ((TimeSinceWin32Epoch - lPwdLastSet) >= maxPwdAge)
{
System.out.println("********* EXPIRED **************");
}
else
{
System.out.println("********* NOT EXPIRED **************");
}
But, with the above code, the TimeSinceWin32Epoch value always seems to be less than 'lPwdLastSet'.
For example, I just did a test where I first reset the password in AD. Then, I ran my test program and got:
lPwdLastSet = 128014798644537904
TimeSinceWin32Epoch = 128014619454130000
maxPwdAge = -37108517437440
Can anyone tell me what I'm doing wrong?
Thanks,
Jim
.
- Prev by Date: Re: Loading of dll file
- Next by Date: Re: access hashtable within a hashtable
- Previous by thread: access hashtable within a hashtable
- Next by thread: Trouble compiling from command-line
- Index(es):