Jump to content

Password Age


Recommended Posts

Hi!

I'm trying to convert some KixTart scripts to AutoIt. I would like to get the password age of the current user like the macro "@PWAGE" in Kix. Is it possible?

Thanx for you time! :D

Edited by Mitch03
Link to comment
Share on other sites

Hmm... i tryed, but unsuccessful :D

$USER_MODALS_INFO_0 = DllStructCreate("dword;dword;dword;dword;dword")

$aRet = DllCall("Netapi32.dll", "int", "NetUserModalsGet", "ptr", 0, "dword", 0, _
                "ptr", DllStructGetPtr($USER_MODALS_INFO_0))
                
ConsoleWrite("DllReturn = " & $aRet[0] & @LF)
ConsoleWrite("DllStruct = " & DllStructGetData($USER_MODALS_INFO_0, 2) & @LF)

DllCall("Netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetPtr($USER_MODALS_INFO_0))

MSDN

Link to comment
Share on other sites

I found this VBScript on the forum - supposedly gets the current password policies:

' This code displays the current settings for the password 
' and account lockout policies.
' ---------------------------------------------------------------
' From the book "Windows Server Cookbook" by Robbie Allen
' Publisher: O'Reilly Media
' ISBN: 0-596-00633-0
' Book web site: http://rallenhome.com/books/winsckbk/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strDomain = "<DomainDN>"   ' e.g. rallencorp.com
' ------ END CONFIGURATION ---------
set objRootDSE = GetObject("LDAP://" & strDomain & "/RootDSE")
set objDomain  = GetObject("LDAP://" & _
                           objRootDSE.Get("defaultNamingContext") )

' Hash containing the domain password and lockout policy attributes
' as keys and the units (e.g. minutes) as the values 
set objDomAttrHash = CreateObject("Scripting.Dictionary")
objDomAttrHash.Add "lockoutDuration", "minutes"
objDomAttrHash.Add "lockoutThreshold", "attempts"
objDomAttrHash.Add "lockoutObservationWindow", "minutes"
objDomAttrHash.Add "maxPwdAge", "minutes"
objDomAttrHash.Add "minPwdAge", "minutes"
objDomAttrHash.Add "minPwdLength", "characters"
objDomAttrHash.Add "pwdHistoryLength", "remembered"
objDomAttrHash.Add "pwdProperties", " "

' Iterate over each attribute and print it
for each strAttr in objDomAttrHash.Keys
   if IsObject( objDomain.Get(strAttr) ) then
      set objLargeInt = objDomain.Get(strAttr)
      if objLargeInt.LowPart = 0 then
         value = 0
      else
         value = Abs(objLargeInt.HighPart * 2^32 + objLargeInt.LowPart)
         value = int ( value / 10000000 )
         value = int ( value / 60 )
      end if
   else 
      value = objDomain.Get(strAttr)
   end if
   WScript.Echo strAttr & " = " & value & " " & objDomAttrHash(strAttr)
next

'Constants from DOMAIN_PASSWORD_INFORMATION
Set objDomPassHash = CreateObject("Scripting.Dictionary")
objDomPassHash.Add "DOMAIN_PASSWORD_COMPLEX", &h1
objDomPassHash.Add "DOMAIN_PASSWORD_NO_ANON_CHANGE", &h2
objDomPassHash.Add "DOMAIN_PASSWORD_NO_CLEAR_CHANGE", &h4
objDomPassHash.Add "DOMAIN_LOCKOUT_ADMINS", &h8
objDomPassHash.Add "DOMAIN_PASSWORD_STORE_CLEARTEXT", &h16
objDomPassHash.Add "DOMAIN_REFUSE_PASSWORD_CHANGE", &h32

' The PwdProperties attribute requires special processing because 
' it is a flag that holds multiple settings.
for each strFlag In objDomPassHash.Keys
  if objDomPassHash(strFlag) and objDomain.Get("PwdProperties") then 
    WScript.Echo "  " & strFlag & " is enabled"
  else
    WScript.Echo "  " & strFlag & " is disabled"
  end If
next

Das Häschen benutzt Radar

Link to comment
Share on other sites

@all

Maybe this can get you all going.

$strComputer = "."
$userName = @UserName

 $objWMIService = ObjGet("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

 $colItems = $objWMIService.ExecQuery ("Select * from Win32_NetworkLoginProfile where caption = '" & StringUpper($userName) &"'")

For $objItem in $colItems
        
    Consolewrite ("Password Age: " & int($objItem.PasswordAge) & " - DD/HH/MM/SS" & @CR) 

Next

regards

ptrex

Link to comment
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
 Share

  • Recently Browsing   0 members

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