Created
September 29, 2016 14:20
-
-
Save AshUK/dd9b1c42a7ceb072b7e0730340a41299 to your computer and use it in GitHub Desktop.
Active Directory - LDAP Time Stamps to JS Date()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LdapTimeStapToDate(ldapTimeStamp) { | |
var sec = Math.round(ldapTimeStamp / 10000000); | |
sec -= 11644473600; | |
return new Date(sec * 1000); | |
} | |
function Ldap2TimeStapToDate(ldap) { | |
var year = ldap.substr(0, 4); | |
var month = ldap.substr(4, 2); | |
var day = ldap.substr(6, 2); | |
var hour = ldap.substr(8, 2); | |
var minute = ldap.substr(10, 2); | |
var second = ldap.substr(12, 2); | |
return new Date(Date.UTC(year, month - 1, day, hour, minute, second)); | |
} | |
var lastLogin = LdapTimeStapToDate(parseInt(aduser.lastLogonTimestamp)); | |
var passwordLastSet = LdapTimeStapToDate(parseInt(aduser.pwdLastSet)); | |
var lastUpdated = Ldap2TimeStapToDate(aduser.whenChanged.toString()); | |
var accountCreated = Ldap2TimeStapToDate(aduser.whenCreated.toString()); | |
var inboxCreated = Ldap2TimeStapToDate(aduser.msExchWhenMailboxCreated.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment