Page 1 of 1 1
Topic Options
#205484 - 2012-07-24 06:55 PM @PWAGE not changing value
JH1 Offline
Just in Town

Registered: 2012-07-22
Posts: 1
Loc: FL USA
KiXtart version: 4.61, Win XP SP3. Using wkix32.exe with -i running tokenized scripts.

Scenario: I wrote a simple script that checks for a VPN connection to the company network once per minute. When it detects that the VPN has just been connected, it calls a sub script that checks the user's password age and notifies the user if expiration will occur in < 8 days or the password has already expired.

Problem: The master script runs full time. Once the script has run and detected expiration is < 8 days, the value of @PWAGE seems to be cached by KiXtart. Testing on later days always return the same value for @PWAGE.

Fire a new instance of wkix32.exe with the same script and voila, the correct value for @PWAGE is detected.

Anyone ever seen this? Any suggestions? The only thing I can come up with is to fire a separate script in another instance of wkix32.exe using SHELL instead of using a CALL in the master script.

Note: all variables shown below are dim'd in the called subscript. Global variables are not used.

$PWExpire = 0
$PWDAYSOLD = 0

$PWDAYSOLD = @PWAGE
$PWExpire = 31 - $PWDAYSOLD

If $PWExpire < 8
$TextInMessage = "The password for your " + $UserDomain + " user account " + $DomainUsername + " will expire in " + $PWExpire + " days." + CHR(10) + CHR(10) + "To change your password, press <CTRL> <ALT> <DEL> and select Change Password" + " with your VPN client connected."
$MsgToDeliver = 1
GoTo POSTMSG
EndIf

Top
#205485 - 2012-07-24 07:28 PM Re: @PWAGE not changing value [Re: JH1]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Welcome to KORG!

That macro might be set only upon Kix startup. Kix was originally designed as a logon script processor, so that value may not have been expected to change.

If this is the case, then a Shell would solve the problem as it would retrieve the current value. Of course, this invokes a new copy of Kix every minute, but is simple to implement.

A better solution might be to use one of the AD or LDAP Query UDFs and obtain the password age directly from AD.

I have some tools that do this - let me rummage around in the toolbox and see what I can find.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#205486 - 2012-07-24 07:59 PM Re: @PWAGE not changing value [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Here's a code snippet from one of my apps that gathers user info. I've added the code to display the results and illustrate how to use TimeConvert and TimeDiff UDFs to calculate differences in time and convert cTime to date/time and back.

Glenn
 Code:
Break On

Dim $, $colItems, $objItem
Dim $Filter[0]

$ = SetOption('explicit', 'Off')
$ = SetOption('WrapAtEOL', 'On')
$ = SetOption('NoVarsInStrings', 'On')
$ = SetOption('NoMacrosInStrings', 'On')

$UserID = '%USERDOMAIN%/%USERNAME%'


;=============================================================================================
; The following two UDFs need to be downloaded and either called or placed into the script
Call '%KixLibPath%\TimeConvert.kxf'
Call '%KixLibPath%\TimeDiff.kxf'
;=============================================================================================


  Dim $objUser, $ary_DATA[13], $Tmp

  $objUser = getobject('WinNT://' + $UserID  + ',user')
  @SERROR ?

  If $objUser
    $ary_Data[5]  = $objUser.LastLogin			; Last login date
    $ary_Data[6]  = $objUser.BadLoginCount		; # bad logins
    $ary_Data[7]  = $objUser.BadLoginAddress		; Last bad login from
    $ary_Data[8]  = $objUser.PasswordAge 		; seconds since last pw change
    $ary_Data[9]  = $objUser.PasswordExpirationDate	; date password expires
    $ary_Data[10] = $objUser.IsAccountLocked		; True if account is locked
    $ary_Data[11] = $objUser.AccountDisabled		; True if account is disabled
    $ary_Data[12] = $objUser.PasswordExpired		; True if password is expired (must change on next login)
  EndIf



; display the results
For $X = 5 to 12
 $X '.' Chr(9) $ary_DATA[$X] ?
Next
?

; When was the last password change
'Password last changed on: '
If $ary_DATA[8] > 0
  $LastChange = TimeConvert(TimeConvert(@DATE + ' ' + @TIME) - $ary_DATA[8])
  $LastChange ?
EndIf
?

; How old is the password?
'Password age is: '
If $ary_DATA[8] > 0
  TimeDiff($LastChange, 'Today', 'D') ' days' ? 
EndIf

quit 0
_________________________
Actually I am a Rocket Scientist! \:D

Top
#205487 - 2012-07-24 08:07 PM Re: @PWAGE not changing value [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
 Code:
$usr = GetObject("WinNT://"+@LDomain+"/"+@UserID+", user" )
$PWAGE = ((($usr.Passwordage/60)/60)/24)-1

? "PW is "+$PWAGE+" days old."
get $

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 793 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.127 seconds in which 0.098 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org