#include #include #include Global $g_iAdminTime Global $g_sAdminPwd _Get_Local_Admin() Func _Get_Local_Admin() Local $aProperties, $aType[4] = ["3", "h", "n", "s"] Local $iDateCalc, $iAdminTime If @UserName = "Administrator" Then Return False _AD_Open() If @error Then _ArrayDisplay(_AD_GetLastADSIError(), "Error: _AD_Open", Default, 32) Else $aProperties = _AD_GetObjectProperties(@ComputerName & "$", "ms-Mcs-AdmPwd,ms-Mcs-AdmPwdExpirationTime") If Not @error Then $g_sAdminPwd = $aProperties[1][1] $g_iAdminTime = _Epoch2Date($aProperties[2][1]) $iAdminTime = _SwapDate($g_iAdminTime) ConsoleWrite(@ComputerName & "\Administrator" & @CRLF & $g_sAdminPwd & @CRLF & @CRLF) For $i = 1 To $aType[0] $iDateCalc = _DateDiff($aType[$i], _NowCalcDate() & " " & _NowTime(5), $iAdminTime) ConsoleWrite("Type: " & $aType[$i] & @CRLF & "_NowCalcDate: " & _NowCalcDate() & " " & _NowTime(5) & @CRLF & "$iAdminTime: " & _ $iAdminTime & @CRLF & "$g_iAdminTime: " & $g_iAdminTime & @CRLF) If Not @error Then Switch $iDateCalc Case 0 If $i <> $aType[0] Then ContinueLoop Else ExitLoop EndIf Case Else ConsoleWrite("Time Left: " & $iDateCalc & " " & $aType[$i] & @CRLF & "$g_iAdminTime: " & $g_iAdminTime & @CRLF) ExitLoop EndSwitch Else ConsoleWrite("_DateDiff Error:" & @error & @CRLF) ExitLoop EndIf Next Else ;|1 - $vObject could not be found ;|2 - No values for the specified property. The property in error is returned as the function result ;|3 - Error retrieving $vObject. @Extended is set to the error returned by LDAP ConsoleWrite("_AD_GetObjectProperties() Error: " & @error & @CRLF) EndIf EndIf _AD_Close() EndFunc ;==>__Get_Local_Admin Func _SwapDate($iTime) Local $aMyDate, $aMyTime $iTime = StringStripWS($iTime, 2) Local $sAMPM = StringRight($iTime, 2) _DateTimeSplit($iTime, $aMyDate, $aMyTime) If $sAMPM = "PM" Then $aMyTime[1] += 12 ElseIf $sAMPM = "AM" Then $aMyTime[1] = "0" & $aMyTime[1] EndIf For $i = 1 To $aMyDate[0] If StringLen($aMyDate[$i]) = 1 Then $aMyDate[$i] = "0" & $aMyDate[$i] Next For $i = 1 To $aMyTime[0] If StringLen($aMyTime[$i]) = 1 Then $aMyTime[$i] = "0" & $aMyTime[$i] Next Local $sMyTime = $aMyDate[3] & "/" & $aMyDate[1] & "/" & $aMyDate[2] & " " & $aMyTime[1] & ":" & $aMyTime[2] & ":" & $aMyTime[3] Return $sMyTime EndFunc ;==>SwapDate Func _Epoch2Date($iTime) Local $sOutput = "" Local $iPID = Run(@ComSpec & " /c " & "w32tm.exe /ntte " & $iTime, "", @SW_HIDE, 2) While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop WEnd $sOutput = StringSplit($sOutput, " - ", 2 + 1) Return $sOutput[1] EndFunc ;==>Epoch2Date