?
Solved

Sample Code to Compute Password Expiration for Active Directory

Posted on 2002-05-07
6
Medium Priority
?
959 Views
Last Modified: 2012-05-04
I need to write some JNDI code that determines the date on which an Active Directory user's password will expire.  If anyone could point me to an example or code snippet I would really appreciate it.  In AD the pwdLastSet attribute stores the number of elapsed seconds sin Jan 1, 1970.  I have written code to get the value convert it to a long and pass the value to the java.util.Date constructor.  I am running into a problem when I try to multiply the value retrived from AD * 1000 to get the elapsed milliseconds.  When I do the multiplication I receive a negative number.  Anyway any help would be greatly appreciated.

Thanks in advance.
0
Comment
Question by:ubsjmg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6994693
Hi
could you sent your source?

May be it's simple problem: long millis = (long)pwdLastSet * (long)1000;

Best regards
Andrey
0
 

Author Comment

by:ubsjmg
ID: 6994801
Hi Andre,
     Here is my code snippet.  The value I retrieve from AD is 126640664549531250.  

if(attrId.equalsIgnoreCase("pwdLastSet")){
for(Enumeration vals = attr.getAll(); vals.hasMoreElements();){
 String lvalue = (String)vals.nextElement();
 System.out.println("Number of Seconds Un Converted: " +   lvalue);
 long lNumSeconds = Long.parseLong(lvalue);
 System.out.println("Number of Milliseconds: " + (lNumSeconds * 1000));
 Date ldateValue = new Date(lNumSeconds);
  DateFormat df1 = DateFormat.getDateInstance   format.SHORT);                    
  System.out.println(df1.format(ldateValue));
 }//for
}//if
0
 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6995889
Hi ubsjmg,
your AD's value is too big (Nov 26, 4015052)
and 126640664549531250 sec * 1000 = ~4015052000 years

Check your AD's repository ... may be 126640664549531250 is default UNDEFINED value ?

It looks like 126640664549531250 is two concatenated strings 126640664sec + 549531250sec...

other ideas?

Best regards
Andrey
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ubsjmg
ID: 6996555
I agree.  I wrote some code that returned the number of elapsed milliseconds since Jan 1, 1970 and found the value to be much smaller.  I have asked a question of our Microsoft contact to tell me what that Value represents.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8710037
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- To be PAQ'ed and points refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 8774370
Per Recommendation,

PashaMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question