You could run my login script with no resource records configured. Put "kix32.exe kixtart.kix --D" in your profile. It will create a LoginDebug.log file in your %USERPROFILE% directory as shown above, which will have the PRIV and LPRIV values. If they are correct during login AND after login, the logic is correct and there's an issue somewhere in your code.

Our script has extensive debug and perflog messages throughout the code. You'd have to do something similar to your script.

There's a fMSG UDF library on my web site.. I use it for all kinds of output in scripts. The command
$Msg = 'The value of X is ' + $X + '.'
fMsg($Msg, , 0, 20)
This will write the message to the log file defined in $MSG_LOG_ only if $DEBUG is true. Both of these are Global vars. If DEBUG is false, no output is written. fMsg allows you to write one message to both screen and log or separate screen/log messages. You can suppress newlines to continue writing on the same line, and the "20" is a mode value that controls how and where the message is displayed - 20 is Log Only and Debug Only. You can even change the 0 to a different value so the value of DEBUG must be greater than that value, permitting terse to verbose debug messages. \:\)

Actually I am a Rocket Scientist! \:D