Hi,
I try to query from the AD plugin of the orchestrator the last logon of computer with the following lines.
var winComputerLastLogonDate = computerResult.getAttribute('lastLogon');
var unixComputerLastLogonDate = (winComputerLastLogonDate-116444736000000000)/100000
var pwdate = new Date(Math.round(unixComputerLastLogonDate));
System.log(pwdate);
The code was written with the following forum help:
Check when the password will expire for an AD User
However I receive a date in 1974...
How can I fix it?
Thanks!
Hi,
You have one more 0 in the expression. The time in lastLogon attribute is the number of 100 nanosecond intervals since Jan 1, 1601. So to get milliseconds, you need to divide not by 100000 but by 10000.
Try with this code snippet which is a bit clearer
var lastLogonDate = computerResult.getAttribute('lastLogon');
var t = +lastLogonDate.substring(0, lastLogonDate.length - 4);
var e = Date.UTC(1601, 0, 1);
var pwdate = new Date(e + t);
System.log(pwdate);
Hi,
You have one more 0 in the expression. The time in lastLogon attribute is the number of 100 nanosecond intervals since Jan 1, 1601. So to get milliseconds, you need to divide not by 100000 but by 10000.
Try with this code snippet which is a bit clearer
var lastLogonDate = computerResult.getAttribute('lastLogon');
var t = +lastLogonDate.substring(0, lastLogonDate.length - 4);
var e = Date.UTC(1601, 0, 1);
var pwdate = new Date(e + t);
System.log(pwdate);