茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1670865 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00004.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2022/11/1 9:35:33
Timestamp from LDAP (ActiveDirectories lastLogonTimestamp)

Question

If I get a Timestamp it's ms since Epoch
1143584229619

But in LDAP I get a value from the timestamp more like
127877417297554938

First though was maybe ms since time of '01/01/0000' or something but it does not add up that way.

Does anyone know what the timestamp maybe; and how I can convert it into something Java can use.

Thanks in advance.

--------------------------------------------------------------------------------

Answers

Hi

lastLogonTimeStamp seems to be the no of 100 nano second intervals starting from 0000 hrs 1/1/1601.

This is similiar to windows file time format and .NET has support to create a System.DateTime object out of this value.. Note the sample here, using the long value that you had provided and watch the date being recreated..

.NET Sample :
import  System.*;
class Test
{
    public static void main(String args[])

    {
    DateTime dt=DateTime.FromFileTime(127877417297554938L);
    System.out.println(dt);
    }
}


Java Sample :
If you want to create a java date object out of this value, please try following this sample, where i have used an adjustment factor to convert the lastLogonTimestamp value into a Date object..

import  java.util.*;
class Test
{
    public static void main(String args[])
    {

           long llastLogonAdjust=11644473600000L;  // adjust factor for converting it to java
                                                                                 //date Epoch
           Date lastLogon = new Date(127877417297554938L/10000-llastLogonAdjust); //
           System.out.println(lastLogon);
    }
}


Thanks

--------------------------------------------------------------------------------

All replies

Hi

lastLogonTimeStamp seems to be the no of 100 nano second intervals starting from 0000 hrs 1/1/1601.

This is similiar to windows file time format and .NET has support to create a System.DateTime object out of this value.. Note the sample here, using the long value that you had provided and watch the date being recreated..

.NET Sample :
import  System.*;
class Test
{
    public static void main(String args[])

    {
    DateTime dt=DateTime.FromFileTime(127877417297554938L);
    System.out.println(dt);
    }
}


Java Sample :
If you want to create a java date object out of this value, please try following this sample, where i have used an adjustment factor to convert the lastLogonTimestamp value into a Date object..

import  java.util.*;
class Test
{
    public static void main(String args[])
    {

           long llastLogonAdjust=11644473600000L;  // adjust factor for converting it to java
                                                                                 //date Epoch
           Date lastLogon = new Date(127877417297554938L/10000-llastLogonAdjust); //
           System.out.println(lastLogon);
    }
}


Thanks

原文出處:Timestamp from LDAP (ActiveDirectories lastLogonTimestamp)


冷日:
簡言之,就是 Windows AD 的時間不是 UnixTimestamp!
所以有一個誤差值:11644473600000L

以下是Java Ldap convert lastLogonTimestamp to DateTime - Stack Overflow提供的解答:
To convert a Win32 filetime string to Date, use:

long fileTime = (Long.parseLong(inputDateString) / 10000L) - 
11644473600000L;
Date inputDate = new Date(fileTime);


To convert a Date to Win32 filetime, use:
long fileTime = (inputDate.getTime() + 11644473600000L) * 10000L;
String outputDate = Long.toString(fileTime);


e.g. 131220409910000000 will be converted to 2016/10/27 14-23-11 and vice versa

Check this url for a nice online epoch/filetime converter:http://www.epochconverter.com/ldap

內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|