Solved

Sample Code to Compute Password Expiration for Active Directory

Posted on 2002-05-07
6
936 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:ubsjmg
Comment Utility
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
Comment Utility
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
Comment Utility
Per Recommendation,

PashaMod
Community Support Moderator @Experts Exchange
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now