Jump to content

Recommended Posts

Posted

I would really like to get this VBScript into AutoIT, but I have no VB background. Can someone make this work? :)

set objRoot = getobject("LDAP://RootDSE")
set objDomain = getobject("LDAP://" & objRoot.get("defaultNamingContext"))

maximumPasswordAge = int(Int8ToSec(objDomain.get("maxPwdAge")) / 86400) 'convert to days
minimumPasswordAge = Int8ToSec(objDomain.get("minPwdAge")) / 86400  'convert to days
minimumPasswordLength = objDomain.get("minPwdLength")
accountLockoutDuration = Int8ToSec(objDomain.get("lockoutDuration")) / 60  'convert to minutes
lockoutThreshold = objDomain.get("lockoutThreshold") 
lockoutObservationWindow = Int8ToSec(objDomain.get("lockoutObservationWindow")) / 60 'convert to minutes
passwordHistory = objDomain.get("pwdHistoryLength")

wscript.echo "Maximum Password Age: " & maximumPasswordAge & " days" & vbcrlf & _
         "Minimum Password Age: " & minimumPasswordAge & " days" & vbcrlf & _
         "Enforce Password History: " & passwordHistory & " passwords remembered" & vbcrlf & _
         "Minimum Password Length: " & minimumPasswordLength & " characters" & vbcrlf & _
         "Account Lockout Duration: " & accountLockoutDuration & " minutes" & vbcrlf & _
         "Account Lockout Threshold: " & lockoutThreshold & " invalid logon attempts" & vbcrlf & _
         "Reset account lockout counter after: " & lockoutObservationWindow & " minutes"
         

Function Int8ToSec(ByVal objInt8)
        ' Function to convert Integer8 attributes from
        ' 64-bit numbers to seconds.
        Dim lngHigh, lngLow
        lngHigh = objInt8.HighPart
        ' Account for error in IADsLargeInteger property methods.
        lngLow = objInt8.LowPart
        If lngLow < 0 Then
            lngHigh = lngHigh + 1
        End If
        Int8ToSec = -(lngHigh * (2 ^ 32) + lngLow) / (10000000)
End Function

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

Amazingly, I need this too just last week... here is what I came up with... :)

#Include <Date.au3>

TraySetToolTip("Active Directory... Processing")

_Demo($DomainString = "dc=domain,dc=com", $HostName = @ComputerName)
Exit

Func _Demo($DomainString = "dc=domain,dc=com", $HostName = @ComputerName)
    Local $SQL = "SELECT cn, lastLogon, pwdLastSet, operatingSystemVersion FROM 'LDAP://" & $DomainString & "' WHERE objectcategory='computer' AND cn='" & $HostName & "'"
    Local $RecordSet = _ActiveDirectory($SQL)
    Local $xmlDomDoc = ObjCreate("MSXML.DOMDocument")
    Local $Data = ""
    
    $RecordSet.MoveFirst()
    
    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "Reformating Data...", 5)

    While Not $RecordSet.EOF        
        $Data &= _
            $RecordSet.Fields("cn"                      ).Value  & "," & _
            $RecordSet.Fields("operatingSystemVersion"  ).Value  & "," & _
            _DecodeMetricTime($RecordSet.Fields("lastLogon" ).Value) & "," & _
            _DecodeMetricTime($RecordSet.Fields("pwdLastSet").Value) & @CRLF
    
        $RecordSet.MoveNext
    WEnd
    
    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "Saving formated data to file.", 5)
    Local $File = FileOpen("C:\ADSI.csv", 2 + 8)
    
    FileWrite($File, $Data)
    FileClose($File)
    
    ;## Clean Up
        $RecordSet.Close()
        $RecordSet.ActiveConnection.Close()

    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "File Saved", 5)

    ShellExecute("C:\ADSI.csv", "", "", "open")
    
    _Alert("Operation Complete")
    Sleep(5000)


EndFunc

    Func _Alert($Message, $Type = 1)
        ;## Tray Update
            TrayTip("", "", 1)
            TrayTip(" - ", $Message, 5, $Type)
        ;## SysLog Update
            ;TODO
        ;## Console
            ConsoleWrite(StringFormat('Alert: %d\n-----------------------------------------------------------\n  %s\n\n', $Type, $Message))
        ;## File Log
            ;_Log(StringFormat('<alert type="%d">%s</alert>', $Type, $Message))
    EndFunc

Func _ActiveDirectory($SQL, $UserID = Default, $UserPW = Default)
    Local Const $ADS_SCOPE_SUBTREE = 2
    Local Const $ADS_CHASE_REFERRALS_ALWAYS = 0x60
    
    Local $Connect, $Command, $Records, $RecordSet
    
    ;## Validate Parameters
        If Not IsString($SQL)       Then Return SetError(1, 0, 0)
        If Not IsString($UserID) And _
            $UserID <> Default      Then Return SetError(2, 0, 0)
        If Not IsString($UserPW) And _
            $UserPW <> Default      Then Return SetError(3, 0, 0)
    
    ;## Define ADO Connection
        $Connect = ObjCreate("ADODB.Connection")
        $Connect.Provider = "ADsDSOObject"
        
        $True = True
        
        _Alert("Connecting to Server...")
        
        If $UserID <> Default Then 
            If $UserPW = Default Then $UserPW = InputBox("Electronic Inventory - ADSI", "Please enter password:" & @CRLF & @CRLF & "  User ID = '" & $UserID & "'", "", "*")
            $Connect.Properties("User ID")          = $UserID
            $Connect.Properties("Password")         = $UserPW
            $Connect.Properties("Encrypt Password") = 1 
            $Connect.Open("DS Query", $UserID, $UserPW)
        Else
            $Connect.Open("DS Query")
        EndIf
        
        _Alert("Connected")
        
    ;## Define ADO Command
        $Command = ObjCreate("ADODB.Command")
        $Command.ActiveConnection = $Connect
        
        $Command.Properties("Chase referrals")  = $ADS_CHASE_REFERRALS_ALWAYS
        $Command.Properties("Page Size")        = 1000
        $Command.Properties("Searchscope")      = $ADS_SCOPE_SUBTREE
        
        $Command.CommandText = $SQL
        
    ;## Execute and Read Data
        _Alert("Poling Data...")
        $RecordSet = $Command.Execute()
        _Alert("Data Aquisition Complete")
        
        $RecordSet.MoveFirst()
        
        Return $RecordSet
EndFunc

Func _DecodeMetricTime($TimeObject)
    Local $FileTime, $Formated, $Pointer
    
    #cs **** History Leason: Metric Time
        http://en.wikipedia.org/wiki/Metric_time
        http://msdn.microsoft.com/en-us/library/ms724284.aspx
    #ce
    
    ;## Convert TimeObject to a Microsoft FileTime DLLStructure
        $FileTime = DllStructCreate($tagFILETIME)
        DllStructSetData($FileTime, "Hi", $TimeObject.HighPart)
        DllStructSetData($FileTime, "Lo", $TimeObject.LowPart)
        
    ;## Convert from UTC to Local
        $FileTime = _Date_Time_FileTimeToLocalFileTime(DllStructGetPtr($FileTime))
        
    ;## Decode FileTime to human readable string
        $Formated = _Date_Time_FileTimeToStr($FileTime)
    
    ;## DEBUG
        _Alert("HighPart = " & $TimeObject.HighPart & @CRLF & _
             "  LowPart  = " & $TimeObject.LowPart & @CRLF & _
             "  Formated = " & $Formated)
        
        Return $Formated
EndFunc
    
Func _Decode64Time($TimeObject) ;## Decode common 64 bit time fields
    Local $TimeValue
    
    ;## Validate Parameters
        If Not IsObj($TimeObject) Then Return SetError(1, 0, 0)
    
    _Alert("HighPart = " & $TimeObject.HighPart)
    _Alert("LowPart = " & $TimeObject.LowPart)
    
    ;## Value is nanoseconds since 1601/01/01
    ;## Convert the value to Days since 1601/01/01
        $TimeValue   = $TimeObject.HighPart * (2^32) + $TimeObject.LowPart
        $TimeValue  /= (60 * 10000000)
        $TimeValue  /= 1440
    
    ;## Calucate get the date / time segmented values
        $Days        = Int($TimeValue)
        $Hours       = ($TimeValue - $Days) * 24
        $Minutes     = ($Hours - Int($Hours)) * 60
        $Seconds     = ($Minutes - Int($Minutes)) * 60
    
    ;## Get Time segments absolute values
        $Hours      = Int($Hours)
        $Minutes    = Int($Minutes)
        $Seconds    = Int($Seconds)
    
    ;## Format the time values into a standard format
        $Time = StringFormat("%02s:%02s:%02s", $Hours, $Minutes, $Seconds)

    ;## Calculate the final date value
        $Date = _DateAdd("d", $Days, "1601/01/01")
    
    ;## Format Final Date / Time Format and return value
        $DateTime   = $Date & " " & $Time
        
        _Alert("Formated = " & $DateTime)
        Return $DateTime
    
EndFunc

--- TTFN

Posted

Thanks, but this doesn't appear to get the same data...

I'm looking for the same exact results of the VBScript I posted, only in values (variables) I can capture and use in other scripts ...

Amazingly, I need this too just last week... here is what I came up with... :)

#Include <Date.au3>

TraySetToolTip("Active Directory... Processing")

_Demo($DomainString = "dc=domain,dc=com", $HostName = @ComputerName)
Exit

Func _Demo($DomainString = "dc=domain,dc=com", $HostName = @ComputerName)
    Local $SQL = "SELECT cn, lastLogon, pwdLastSet, operatingSystemVersion FROM 'LDAP://" & $DomainString & "' WHERE objectcategory='computer' AND cn='" & $HostName & "'"
    Local $RecordSet = _ActiveDirectory($SQL)
    Local $xmlDomDoc = ObjCreate("MSXML.DOMDocument")
    Local $Data = ""
    
    $RecordSet.MoveFirst()
    
    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "Reformating Data...", 5)

    While Not $RecordSet.EOF        
        $Data &= _
            $RecordSet.Fields("cn"                      ).Value  & "," & _
            $RecordSet.Fields("operatingSystemVersion"  ).Value  & "," & _
            _DecodeMetricTime($RecordSet.Fields("lastLogon" ).Value) & "," & _
            _DecodeMetricTime($RecordSet.Fields("pwdLastSet").Value) & @CRLF
    
        $RecordSet.MoveNext
    WEnd
    
    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "Saving formated data to file.", 5)
    Local $File = FileOpen("C:\ADSI.csv", 2 + 8)
    
    FileWrite($File, $Data)
    FileClose($File)
    
    ;## Clean Up
        $RecordSet.Close()
        $RecordSet.ActiveConnection.Close()

    TrayTip("", "", 1)
    TrayTip("Electric Inventory - ADSI", "File Saved", 5)

    ShellExecute("C:\ADSI.csv", "", "", "open")
    
    _Alert("Operation Complete")
    Sleep(5000)


EndFunc

    Func _Alert($Message, $Type = 1)
        ;## Tray Update
            TrayTip("", "", 1)
            TrayTip(" - ", $Message, 5, $Type)
        ;## SysLog Update
            ;TODO
        ;## Console
            ConsoleWrite(StringFormat('Alert: %d\n-----------------------------------------------------------\n  %s\n\n', $Type, $Message))
        ;## File Log
            ;_Log(StringFormat('<alert type="%d">%s</alert>', $Type, $Message))
    EndFunc

Func _ActiveDirectory($SQL, $UserID = Default, $UserPW = Default)
    Local Const $ADS_SCOPE_SUBTREE = 2
    Local Const $ADS_CHASE_REFERRALS_ALWAYS = 0x60
    
    Local $Connect, $Command, $Records, $RecordSet
    
    ;## Validate Parameters
        If Not IsString($SQL)       Then Return SetError(1, 0, 0)
        If Not IsString($UserID) And _
            $UserID <> Default      Then Return SetError(2, 0, 0)
        If Not IsString($UserPW) And _
            $UserPW <> Default      Then Return SetError(3, 0, 0)
    
    ;## Define ADO Connection
        $Connect = ObjCreate("ADODB.Connection")
        $Connect.Provider = "ADsDSOObject"
        
        $True = True
        
        _Alert("Connecting to Server...")
        
        If $UserID <> Default Then 
            If $UserPW = Default Then $UserPW = InputBox("Electronic Inventory - ADSI", "Please enter password:" & @CRLF & @CRLF & "  User ID = '" & $UserID & "'", "", "*")
            $Connect.Properties("User ID")          = $UserID
            $Connect.Properties("Password")         = $UserPW
            $Connect.Properties("Encrypt Password") = 1 
            $Connect.Open("DS Query", $UserID, $UserPW)
        Else
            $Connect.Open("DS Query")
        EndIf
        
        _Alert("Connected")
        
    ;## Define ADO Command
        $Command = ObjCreate("ADODB.Command")
        $Command.ActiveConnection = $Connect
        
        $Command.Properties("Chase referrals")  = $ADS_CHASE_REFERRALS_ALWAYS
        $Command.Properties("Page Size")        = 1000
        $Command.Properties("Searchscope")      = $ADS_SCOPE_SUBTREE
        
        $Command.CommandText = $SQL
        
    ;## Execute and Read Data
        _Alert("Poling Data...")
        $RecordSet = $Command.Execute()
        _Alert("Data Aquisition Complete")
        
        $RecordSet.MoveFirst()
        
        Return $RecordSet
EndFunc

Func _DecodeMetricTime($TimeObject)
    Local $FileTime, $Formated, $Pointer
    
    #cs **** History Leason: Metric Time
        http://en.wikipedia.org/wiki/Metric_time
        http://msdn.microsoft.com/en-us/library/ms724284.aspx
    #ce
    
    ;## Convert TimeObject to a Microsoft FileTime DLLStructure
        $FileTime = DllStructCreate($tagFILETIME)
        DllStructSetData($FileTime, "Hi", $TimeObject.HighPart)
        DllStructSetData($FileTime, "Lo", $TimeObject.LowPart)
        
    ;## Convert from UTC to Local
        $FileTime = _Date_Time_FileTimeToLocalFileTime(DllStructGetPtr($FileTime))
        
    ;## Decode FileTime to human readable string
        $Formated = _Date_Time_FileTimeToStr($FileTime)
    
    ;## DEBUG
        _Alert("HighPart = " & $TimeObject.HighPart & @CRLF & _
             "  LowPart  = " & $TimeObject.LowPart & @CRLF & _
             "  Formated = " & $Formated)
        
        Return $Formated
EndFunc
    
Func _Decode64Time($TimeObject) ;## Decode common 64 bit time fields
    Local $TimeValue
    
    ;## Validate Parameters
        If Not IsObj($TimeObject) Then Return SetError(1, 0, 0)
    
    _Alert("HighPart = " & $TimeObject.HighPart)
    _Alert("LowPart = " & $TimeObject.LowPart)
    
    ;## Value is nanoseconds since 1601/01/01
    ;## Convert the value to Days since 1601/01/01
        $TimeValue   = $TimeObject.HighPart * (2^32) + $TimeObject.LowPart
        $TimeValue  /= (60 * 10000000)
        $TimeValue  /= 1440
    
    ;## Calucate get the date / time segmented values
        $Days        = Int($TimeValue)
        $Hours       = ($TimeValue - $Days) * 24
        $Minutes     = ($Hours - Int($Hours)) * 60
        $Seconds     = ($Minutes - Int($Minutes)) * 60
    
    ;## Get Time segments absolute values
        $Hours      = Int($Hours)
        $Minutes    = Int($Minutes)
        $Seconds    = Int($Seconds)
    
    ;## Format the time values into a standard format
        $Time = StringFormat("%02s:%02s:%02s", $Hours, $Minutes, $Seconds)

    ;## Calculate the final date value
        $Date = _DateAdd("d", $Days, "1601/01/01")
    
    ;## Format Final Date / Time Format and return value
        $DateTime   = $Date & " " & $Time
        
        _Alert("Formated = " & $DateTime)
        Return $DateTime
    
EndFunc

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

Is this what you need?

Global $objRoot = ObjGet("LDAP://RoosDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomin.Get("maxPwdAge"))) / 86400                    ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                        ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60                 ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservartionWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60     ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

$oWhs.Echo("Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes"
            
Func Int8ToSec(ByRef $objInt8)
    Dim $lngHigh, $lngLow
    
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
    
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
    
    Return $lngHigh * (2 ^ 32) + $lngLow) / 10000000
EndFunc

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Posted

It looks very promising, but I can't get it to work... :)

ERROR REPORT:

>Running AU3Check (1.54.13.0) from:C:\Program Files\AutoIt3

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(7,63) : WARNING: $objDomin: possibly used before declaration.

$maximumPasswordAge = Int(Int8ToSec($objDomin.Get("maxPwdAge"))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(21,81) : WARNING: $lockoutObservationWindow: possibly used before declaration.

"Reset account lockout counter after: " & $lockoutObservationWindow &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(21,93) : ERROR: syntax error

"Reset account lockout counter after: " & $lockoutObservationWindow & " minutes"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(26,33) : WARNING: $objInt8: possibly used before declaration.

$lngHigh = $objInt8.HighPart

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(33,41) : ERROR: syntax error

Return $lngHigh * (2 ^ 32) + $lngLow)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(33,53) : ERROR: 'Return' not allowed from global scope.

Return $lngHigh * (2 ^ 32) + $lngLow) / 10000000

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(34,1) : ERROR: syntax error

EndFunc

^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(7,63) : ERROR: $objDomin: undeclared global variable.

$maximumPasswordAge = Int(Int8ToSec($objDomin.Get("maxPwdAge"))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3(7,63) : ERROR: Int8ToSec(): undefined function.

$maximumPasswordAge = Int(Int8ToSec($objDomin.Get("maxPwdAge"))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3 - 6 error(s), 3 warning(s)

Is this what you need?

Global $objRoot = ObjGet("LDAP://RoosDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomin.Get("maxPwdAge"))) / 86400                    ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                        ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60                 ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservartionWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60     ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

$oWhs.Echo("Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes"
            
Func Int8ToSec(ByRef $objInt8)
    Dim $lngHigh, $lngLow
    
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
    
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
    
    Return $lngHigh * (2 ^ 32) + $lngLow) / 10000000
EndFunc

AlmarM

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

Can someone help me get this translated to AutoIT, please? :o

It would be GREATLY appreciated! :)

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

The errors are just typos. Corrected them, but couldn't test...

Global $objRoot = ObjGet("LDAP://RoosDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
;~ Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomain.Get("maxPwdAge"))) / 86400                    ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                        ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60     ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservationWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60  ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

MsgBox(0,"","Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes")
           
Func Int8ToSec($objInt8)
    Dim $lngHigh, $lngLow
   
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
   
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
   
    Return ($lngHigh * (2 ^ 32) + $lngLow) / 10000000
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

Well, there is definite progess being made. It lets me run the script, but nothing displays and I get the following:

C:\Documents and Settings\rosborne\Local Settings\Temp\test.au3 (2) : ==> Variable must be of type "Object".:

Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))

Global $objDomain = ObjGet("LDAP://" & $objRoot^ ERROR

Thank you so much for you continued help!! :)

The errors are just typos. Corrected them, but couldn't test...

Global $objRoot = ObjGet("LDAP://RoosDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
;~ Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomain.Get("maxPwdAge"))) / 86400                    ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                        ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60     ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservationWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60  ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

MsgBox(0,"","Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes")
           
Func Int8ToSec($objInt8)
    Dim $lngHigh, $lngLow
   
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
   
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
   
    Return ($lngHigh * (2 ^ 32) + $lngLow) / 10000000
EndFunc

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

rogerd2u - Do some debugging yourself, its not Christmas yet.

Hint:

Original:

Line1: set objRoot = getobject("LDAP://RootDSE")

Current:

Line1: Global $objRoot = ObjGet("LDAP://RoosDSE")

Posted (edited)

I looked through it for type-o's but didn't find any -- HONESTLY! :):-)

That fixed it! You all are awesome!!

rogerd2u - Do some debugging yourself, its not Christmas yet.

Hint:

Original:

Line1: set objRoot = getobject("LDAP://RootDSE")

Current:

Line1: Global $objRoot = ObjGet("LDAP://RoosDSE")

For those who would like to copy & paste the working code, here it is:

;Function to check Active Directory for Domain password policy settings


Global $objRoot = ObjGet("LDAP://RootDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
;~ Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomain.Get("maxPwdAge"))) / 86400                  ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                       ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60 ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservationWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60 ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

MsgBox(0,"","Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes")
           
Func Int8ToSec($objInt8)
    Dim $lngHigh, $lngLow
   
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
   
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
   
    Return -($lngHigh * (2 ^ 32) + $lngLow) / (10000000)
EndFunc

(Although it looks like negative numbers in several results, but I'm sure I can figure that part out!) :-)

THANKS AGAIN !!!!

Edited by rogerd2u

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

(Although it looks like negative numbers in several results, but I'm sure I can figure that part out!) :-)

THANKS AGAIN !!!!

If you could post the output from VB and AutoIt side by side we can figure it out.

Posted

Window VBScript Result --

Maximum Password Age: 90 days

Minimum Password Age: 1 days

Enforce Password History: 10 passwords remembered

Minimum Password Length: 8 characters

Account Lockout Duration: 3 minutes

Account Lockout Threshold: 7 invalid login attempts

Reset account lockout counter after: 3 minutes

AuotIT Script Result --

Maximum Password Age: -90 days

Minimum Password Age: -1 days

Enforce Password History: 10 passwords remembered

Minimum Password Length: 8 characters

Account Lockout Duration: -3 minutes

Account Lockout Threshold: 7 invalid login attempts

Reset account lockout counter after: -3 minutes

If you could post the output from VB and AutoIt side by side we can figure it out.

Roger O."When people show you who they are, believe them.” --Mark Twain

Posted

Again, a typo in the translation...come on people.

Original:

Int8ToSec = -(lngHigh * (2 ^ 32) + lngLow) / (10000000)

Current:

Return ($lngHigh * (2 ^ 32) + $lngLow) / 10000000

Posted

You 'da man!

Here's the completed code

;Function to check Active Directory for Domain password policy settings


Global $objRoot = ObjGet("LDAP://RootDSE")
Global $objDomain = ObjGet("LDAP://" & $objRoot.Get("defaultNamingContext"))
;~ Global $oWhs = ObjCreate("Wscript.Shell")

$maximumPasswordAge = Int(Int8ToSec($objDomain.Get("maxPwdAge"))) / 86400                  ; Convert to Days
$minimumPasswordAge = Int8ToSec($objDomain.Get("minPwdAge")) / 86400                       ; Convert to Days
$minimumPasswordLength = $objDomain.Get("minPwdLength")
$accountLockoutDuration = Int8ToSec($objDomain.Get("lockoutDuration")) / 60 ; Convert to Minutes
$lockoutThreshold = $objDomain.Get("lockoutThreshold")
$lockoutObservationWindow = Int8ToSec($objDomain.Get("lockoutObservationWindow")) / 60 ; Convert to Minutes
$passwordHistory = $objDomain.Get("pwdHistoryLength")

MsgBox(0,"","Maximum Password Age: " & $maximumPasswordAge & " days" & @CRLF & _
            "Minimum Password Age: " & $minimumPasswordAge & " days" & @CRLF & _
            "Enforce Password History: " & $passwordHistory & " passwords remembered" & @CRLF & _
            "Minimum Password Length: " & $minimumPasswordLength & " characters" & @CRLF & _
            "Account Lockout Duration: " & $accountLockoutDuration & " minutes" & @CRLF & _
            "Account Lockout Threshold: " & $lockoutThreshold & " invalid logon attempts" & @CRLF & _
            "Reset account lockout counter after: " & $lockoutObservationWindow & " minutes")
           
Func Int8ToSec($objInt8)
    Dim $lngHigh, $lngLow
   
    $lngHigh = $objInt8.HighPart
    $lngLow = $objInt8.LowPart
   
    If $lngLow < 0 Then
        $lngHigh = $lngHigh + 1
    EndIf
   
    Return -($lngHigh * (2 ^ 32) + $lngLow) / (10000000)
EndFunc

Again, a typo in the translation...come on people.

Original:

Int8ToSec = -(lngHigh * (2 ^ 32) + lngLow) / (10000000)

Current:

Return ($lngHigh * (2 ^ 32) + $lngLow) / 10000000

Roger O."When people show you who they are, believe them.” --Mark Twain

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...