Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2006

Tip: Looking for answers? Try searching our database.

Help re. checking for password expiration/time comparisons

Thread view: 
ohaya - 31 Aug 2006 08:15 GMT
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
Paul Hamaker - 31 Aug 2006 22:16 GMT
Why do you multiply by 10.000 ?
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com
ohaya - 01 Sep 2006 04:19 GMT
Paul,

I'm not sure... it was code that I found on one of the Sun JNDI forums :)...

Actually, I think that I got it working, thanks to another poster on
that forum.

Jim

> Why do you multiply by 10.000 ?
> --------------------
> Paul Hamaker, SEMM, teaching ICT since 1987
> http://javalessons.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.