2

In Active Directory, "lockOutTime" attribute has a long value. How do I calculate the date and time from that value (in order to find at what time the user is locked)?

Anu
  • 177
  • 1
  • 1
  • 12

2 Answers2

1

I work with this method..

private final static long DIFF_NET_JAVA_FOR_DATES = 11644473600000L + 24 * 60 * 60 * 1000;

Date getDateFromAD(long adLongValue)
{
    long milliseconds = (adLongValue / 10000) - DIFF_NET_JAVA_FOR_DATES;
    Date date = new Date(milliseconds);
    return date;
}
0

Actually no need to add 24 * 60 * 60 * 1000 to DIFF_NET_JAVA_FOR_DATES, which means the following is enough,

private final static long DIFF_NET_JAVA_FOR_DATES = 11644473600000L;

You can double check the result with https://www.epochconverter.com/ldap.

nanoart
  • 11
  • 1
  • 1