GPO login script error


i have script starts vbs file when user logs in on laptop. script in c:\windows\system32 (copied thru gpo).

when user logs in when domain not available error occurs (even when password not changed):

windows scripting host domain not available.

this script:

'a vbs script that goes in to your gpo that displays a popup window telling the user their password expires in # days and that
'the user must click ok to dismiss. it goes in the gpo - user config - policies - admin templates - system - logon - run these
'programs at user logon.  you will also need to add the folder location to ie trusted sites to avoid having a popup asking if
'it should run the script.

'pwexpchk.vbs

      '========================================
    ' first, get the domain policy.
    '========================================
    dim odomain
    dim ouser
    dim maxpwdage
    dim numdays
    dim warningdays

    warningdays = 15

    set logininfo = createobject("adsysteminfo")
    set objuser = getobject("ldap://" & logininfo.username & "")
    strdomaindn = ucase(logininfo.domaindnsname)
    struserdn = logininfo.username


    set odomain = getobject("ldap://" & strdomaindn)
    set maxpwdage = odomain.get("maxpwdage")

    '========================================
    ' calculate the number of days that are
    ' held in this value.
    '========================================
    numdays = ccur((maxpwdage.highpart * 2 ^ 32) + _
                    maxpwdage.lowpart) / ccur(-864000000000)
    'wscript.echo "maximum password age: " & numdays

    '========================================
    ' determine the last time that the user
    ' changed his or her password.
    '========================================
    set ouser = getobject("ldap://" & struserdn)

    '========================================
    ' add the number of days to the last time
    ' the password was set.
    '========================================
    whenpasswordexpires = dateadd("d"numdaysouser.passwordlastchanged)
    fromdate = date
    daysleft = datediff("d",fromdate,whenpasswordexpires)

    'wscript.echo "password last changed: " & ouser.passwordlastchanged

    if (daysleft < warningdaysand (daysleft > -1then
        msgbox "password expires " & daysleft & " dagen" & " op " & whenpasswordexpires & chr(13) & chr(13) & "let op!" & chr(13) & 
   end if

the error in line according scripting host:  set objuser = getobject("ldap://" & logininfo.username & "")

in script there line says folder location of script must added trusted websites, cannot fill c:\windows\system32 in there....


freddie

 
> put err.clear
>
> on error resume next before set objusers line en beneath it:
> if err wscriptquit
>
 
yes - 2 lines before error, 1 line after. aware there
a dot between wscript , quit... "wscript.quit". copy in ,
should happy when offline. , leave in system32, that's not
bad place put it.
 > seems know me it?
 
thanks ;-)
 
unfortunately, cannot teach vbs through forum. suggest
also tutorials (although of newer stuff
powershell). there's script center library @
 
regards, martin
 

no not evil, if know doing: or bad gpos?
wenn meine antwort hilfreich war, freue ich mich über eine bewertung! if answer helpful, i'm glad rating!


Windows Server  >  Group Policy



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...