akb0109 Posted May 12, 2009 Share Posted May 12, 2009 hi, I am trying to write a login script in autoit, one part of which calculate the password age of the current logged in user and display the age and expiring date on his screen when he logs in. As almost a newbie in Autoit, I could not able to find any way to write this script in AutoIt. Can anybody help me to write this script. Thanks In advance for your replies. akb Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 12, 2009 Share Posted May 12, 2009 hi, I am trying to write a login script in autoit, one part of which calculate the password age of the current logged in user and display the age and expiring date on his screen when he logs in. As almost a newbie in Autoit, I could not able to find any way to write this script in AutoIt. Can anybody help me to write this script.Thanks In advance for your replies.akbYou are looking for the $oUser.PasswordLastChanged property of the object. Is this a local account or AD? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
akb0109 Posted May 12, 2009 Author Share Posted May 12, 2009 You are looking for the $oUser.PasswordLastChanged property of the object. Is this a local account or AD? Hi,I am looking for current AD account (logged in) password age. This will be helpful for me if you provide me the tips to write a script to get the information.Thanks againakb Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 12, 2009 Share Posted May 12, 2009 Hi,I am looking for current AD account (logged in) password age. This will be helpful for me if you provide me the tips to write a script to get the information.Thanks againakbGoogle is your friend: How to obtain password expiration date by using LDAP ADSI providerSkip down to the VBScript example and translate to AutoIt. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
akb0109 Posted May 13, 2009 Author Share Posted May 13, 2009 Google is your friend: How to obtain password expiration date by using LDAP ADSI providerSkip down to the VBScript example and translate to AutoIt. Hi, I have tried. After conversion here is the what I get -; ----------------------------------------------------------------------------;; VBScript to AutoIt Converter v0.4;; ----------------------------------------------------------------------------#include <bk-logfile.au3>#include <date.au3>;======================================== ; First, get the domain policy. ;======================================== Dim $oDomain Dim $oUser Dim $maxPwdAge Dim $numDays $strDomainDN = "My Domain" $strUserDN = $strDomainDN & @UserName $oDomain = ObjGet("LDAP://my ldap.com" & $strDomainDN) $maxPwdAge = $oDomain.Get("maxPwdAge") ;======================================== ; Calculate the number of days that are ; held in this value. ;======================================== $numDays = Number(($maxPwdAge.HighPart $* 2 $^ 32) + _ $maxPwdAge.LowPart) (/ Number(-864000000000)) _WriteLog ("Maximum Password Age: " & $numDays) ;======================================== ; Determine the last time that the user ; changed his or her password. ;======================================== $oUser = ObjGet("LDAP://my ldap.com" & $strUserDN) ;======================================== ; Add the number of days to the last time ; the password was set. ;======================================== $whenPasswordExpires = _DateAdd("d", $numDays, $oUser.PasswordLastChanged) _WriteLog ("Password Last Changed: " & $oUser.PasswordLastChanged) _WriteLog ("Password Expires On: " & $whenPasswordExpires) ;======================================== ; Clean up. ;========================================;VA Set $oUser = Nothing;VA Set $maxPwdAge = Nothing;VA Set $oDomain = Nothing _WriteLog ("Done")But it does not work. Lots of commands are not converted to AutoIT. Kindly help. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 13, 2009 Share Posted May 13, 2009 Hi, I have tried. After conversion here is the what I get - CODE; ---------------------------------------------------------------------------- ; ; VBScript to AutoIt Converter v0.4 ; ; ---------------------------------------------------------------------------- #include <bk-logfile.au3> #include <date.au3> ;======================================== ; First, get the domain policy. ;======================================== Dim $oDomain Dim $oUser Dim $maxPwdAge Dim $numDays $strDomainDN = "My Domain" $strUserDN = $strDomainDN & @UserName $oDomain = ObjGet("LDAP://my ldap.com" & $strDomainDN) $maxPwdAge = $oDomain.Get("maxPwdAge") ;======================================== ; Calculate the number of days that are ; held in this value. ;======================================== $numDays = Number(($maxPwdAge.HighPart $* 2 $^ 32) + _ $maxPwdAge.LowPart) (/ Number(-864000000000)) _WriteLog ("Maximum Password Age: " & $numDays) ;======================================== ; Determine the last time that the user ; changed his or her password. ;======================================== $oUser = ObjGet("LDAP://my ldap.com" & $strUserDN) ;======================================== ; Add the number of days to the last time ; the password was set. ;======================================== $whenPasswordExpires = _DateAdd("d", $numDays, $oUser.PasswordLastChanged) _WriteLog ("Password Last Changed: " & $oUser.PasswordLastChanged) _WriteLog ("Password Expires On: " & $whenPasswordExpires) ;======================================== ; Clean up. ;======================================== ;VA Set $oUser = Nothing ;VA Set $maxPwdAge = Nothing ;VA Set $oDomain = Nothing _WriteLog ("Done")But it does not work. Lots of commands are not converted to AutoIT. Kindly help. You ignored correct LDAP path syntax (i.e. "CN=User Name,CN=Users,DC=DCServer,DC=MyDomain,DC=com") and your conversion of the math is funky. I haven't looked, but if the PasswordLastChanged property is in the same format as maxPwdAge, then the same math has to be done to it also. If you just ran it through somebody's VBS-AutoIt converter, then you've got some study and learning curve in front of you. Start with the correct format for $strDomainDN and $strUserDN. The look at the math, for example: $numDays = (($maxPwdAge.HighPart * 2^32) + $maxPwdAge.LowPart) / -864000000000 It's worth learning, so don't get frustrated with it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now