Jump to content
Sign in to follow this  

AD and Integer8 attributes

Recommended Posts


re all !

ok, active directory is really boring, because it uses specific attributes !

so, on this site http://www.rlmueller.net/Programs/Integer8Date.txt

i've found a function to convert those integer to date.

after conversion in autoit, i've several problems, but before to post, i would know if you know

another method to convert it ? i'm afraid of this to slow down the program a little, but if there is not another way...

; ----------------------------------------------------------------------------
; VBScript to AutoIt Converter v0.4
; ----------------------------------------------------------------------------

#include <date.au3>
;#include <bk-logfile.au3>

; Integer8Date.vbs()
; VBScript program demonstrating how to convert an Integer8 attribute,
; such as pwdLastSet, to a date value. The Integer8Date function()
; corrects for the inaccuracy in the HighPart and LowPart methods of
; the IADsLargeInteger interface. It is desirable to have the
; Integer8Date function always return a date, so the main program()
; can compare values to find the latest date. For this reason, if the
; Integer8 attribute has no value, the function returns the date
; 1/1/1601, which is the "zero" date. This really means "never".
; ----------------------------------------------------------------------
; Copyright (c) 2003 Richard L. Mueller
; Hilltop Lab web site - http://www.rlmueller.net
; Version 1.0 - May 21, 2003
; Version 1.1 - June 5, 2003 - Retrieve time zone bias from registry.
; Version 1.2 - October 29, 2003 - Account for very large values.
; Version 1.3 - January 25, 2004 - Modify error trapping.
; You have a royalty-free right to use, modify, reproduce, and
; distribute this script file in any way you find useful, provided that
; you agree that the copyright owner above has no warranty, obligations,
; or liability for such use.

AutoItSetOption("MustDeclareVars", 1)
Dim $strUserDN, $lngTZBias, $objUser, $objPwdLastSet
Dim $objShell, $lngBiasKey, $k

; Obtain local Time Zone bias from machine registry.
 $objShell = ObjCreate("Wscript.Shell")
$lngBiasKey = $objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
  & "TimeZoneInformation\ActiveTimeBias")
If StringUpper($lngBiasKey) = "LONG" Then
  $lngTZBias = $lngBiasKey
$ElseIf StringUpper($lngBiasKey) = "VARIANT()" Then
  $lngTZBias = 0
  For $k = 0 To UBound($lngBiasKey)
    $lngTZBias = $lngTZBias + ($lngBiasKey($k) * $256^$k)

$strUserDN = "cn=test y,ou=TestUSB,dc=test,dc=test"
 $objUser = ObjGet("LDAP://" & $strUserDN)
 $objPwdLastSet = $objUser.pwdLastSet
ConsoleWrite ("Password last set: " & Integer8Date($objPwdLastSet, $lngTZBias))

Func Integer8Date($objDate, $lngBias)
    Local $Return
; Function to convert Integer8 ($64-bit) value to a date, adjusted for
; local time zone bias.
  Dim $lngAdjust, $lngDate, $lngHigh, $lngLow
  $lngAdjust = $lngBias
  $lngHigh = $objDate.HighPart
  $lngLow = $objDate.LowPart
; Account for error in IADslargeInteger property methods.
  If $lngLow < 0 Then
    $lngHigh = $lngHigh + 1
  If ($lngHigh = 0) And ($lngLow = 0) Then
    $lngAdjust = 0
  $lngDate = "#1/1/1601#" + ((($lngHigh * (2 ^ 32)) + $lngLow) / 600000000 - $lngAdjust) / 1440;<==doesn't work
; Trap error if $lngDate is ridiculously huge.
;VA   On Error Resume Next
  $Return = cdate($lngDate); <== "cdate" in autoit ?
  If @error <> 0 Then
;VA  On Error GoTo 0
    $Return = "#1/1/1601#"
;VA   On Error GoTo 0
    Return $Return

thx for any help

i post here the preview of my program

c u

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.