[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Sample Code to Compute Password Expiration for Active Directory

Posted on 2002-05-07
6
Medium Priority
?
967 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
Technology Partners: 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!

 

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 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