ECHAIGNE Posted May 4, 2006 Share Posted May 4, 2006 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 Link to comment Share on other sites More sharing options...
ECHAIGNE Posted May 5, 2006 Author Share Posted May 5, 2006 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now