Solved

Sample Code to Compute Password Expiration for Active Directory

Posted on 2002-05-07
6
938 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exception after setting jdbc session management 2 52
topping1 challenge 7 72
What is the latest versions eclipse neon 2 139
java  and programming certification ? 4 86
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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now