Sign in to follow this  
Followers 0
ECHAIGNE

Ajout De Date

2 posts in this topic

Hi,

I want find in with date a user as logged in AD

In vbs, it works with this code :

Set objUser = GetObject("LDAP://CN=Eric,OU=Users,OU=TEST,DC=TestSrv,DC=Domaine,DC=fr")

Set objLastLogon = objUser.Get("lastLogonTimestamp")

intLastLogonTime = objLastLogon.HighPart * (2^32) + objLastLogon.LowPart

intLastLogonTime = intLastLogonTime / (60 * 10000000)

intLastLogonTime = intLastLogonTime / 1440

Wscript.Echo "Last logon time: " & intLastLogonTime + #1/1/1601#

In Autoit3, the code is

Local $objUser = ObjGet("LDAP://CN=Eric,OU=Users,OU=TEST,DC=TestSrv,DC=Domaine,DC=fr")

Local $objLastLogon = $objUser.Get("lastLogonTimestamp")

Local $intLastLogonTime = $objLastLogon.HighPart * (2^32) + $objLastLogon.LowPart

$intLastLogonTime = $intLastLogonTime / (60 * 10000000)

$intLastLogonTime = $intLastLogonTime / 1440

How can I add the date 01/01/1601 to intLastLogonTime ?

Thanks you

Eric CHAIGNE

Share this post


Link to post
Share on other sites



Hi,

I want find in with date a user as logged in AD

In vbs, it works with this code :

Set objUser = GetObject("LDAP://CN=Eric,OU=Users,OU=TEST,DC=TestSrv,DC=Domaine,DC=fr")
Set objLastLogon = objUser.Get("lastLogonTimestamp")

intLastLogonTime = objLastLogon.HighPart * (2^32) + objLastLogon.LowPart 
intLastLogonTime = intLastLogonTime / (60 * 10000000)
intLastLogonTime = intLastLogonTime / 1440

Wscript.Echo "Last logon time: " & intLastLogonTime + #1/1/1601#

In Autoit3, the code is

Local $objUser = ObjGet("LDAP://CN=Eric,OU=Users,OU=TEST,DC=TestSrv,DC=Domaine,DC=fr")
  Local $objLastLogon = $objUser.Get("lastLogonTimestamp")

  Local $intLastLogonTime = $objLastLogon.HighPart * (2^32) + $objLastLogon.LowPart 
  $intLastLogonTime = $intLastLogonTime / (60 * 10000000)
  $intLastLogonTime = $intLastLogonTime / 1440

How can I add the date 01/01/1601 to intLastLogonTime ?

Thanks you

Eric CHAIGNE

I thinks that I find :

Const $Entre1601et1970 = 116444736000000000

  Local $objUser = ObjGet("LDAP://CN=Eric,OU=Users,OU=TEST,DC=TestSrv,DC=Domaine,DC=fr")
  Local $objLastLogon = $objUser.Get("lastLogonTimestamp")

  Local $intLastLogonTime = $objLastLogon.HighPart * (2^32) + $objLastLogon.LowPart 
 ; Depuis le 01/01/1970
  $intLastLogonTime = $intLastLogonTime - $Entre1601et1970
 ; Conversion en secondes
  Local $intLastLogonTimeS = $intLastLogonTime / 10000000
 ; Conversion en heures
  Local $intLastLogonTimeH = $intLastLogonTimeS / 3600
 ; Conversion en jours
  Local $intLastLogonTimeJ = $intLastLogonTimeH / 24
 ; Temps restant
  Local $intNbHRestant = (Int($intLastLogonTimeH) - Int($intLastLogonTimeJ) * 24) * 3600
  Local $sNewDate = _DateAdd('s', Int($intNbHRestant + Mod($intLastLogonTimeS, 3600)), _
                              _DateAdd('D', Int($intLastLogonTimeJ), "1970/01/01 00:00:00"))
  MsgBox(0,"test", "Date dernier login : " & $sNewDate)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0