Script to set a local user account password to never expire

Discussion in 'Scripting' started by BC, Jan 31, 2006.

  1. BC

    BC Guest

    I am looking for a quick fix to write a script that will set a local user
    accout password to never expires. Our notebooks are part of a windows 2003
    domain. I attempted to user the net user comman, however the expires syntax
    is for the user account not the password.
     
    BC, Jan 31, 2006
    #1
    1. Advertisements

  2. BC

    Umesh Thakur Guest

    Umesh Thakur, Jan 31, 2006
    #2
    1. Advertisements

  3. BC

    zoid Guest

    Ркак применить Ñтот Ñкприт на веÑÑŒ домен?

    Const SEC_IN_DAY = 86400
    Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

    Set objDomain = GetObject _
    ("LDAP://DC=domain_name,DC=ru")
    For Each objUser In objDomain

    If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then
    Wscript.Echo "The password does not expire."
    Else
    dtmValue = objUserLDAP.PasswordLastChanged
    Wscript.Echo "The password was last changed on " & _
    DateValue(dtmValue) & " at " & TimeValue(dtmValue) & VbCrLf & _
    "The difference between when the password was last set" & _
    "and today is " & int(now - dtmValue) & " days"
    intTimeInterval = int(now - dtmValue)

    Set objDomainNT = GetObject("WinNT://fabrikam")
    intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")
    If intMaxPwdAge < 0 Then
    WScript.Echo "The Maximum Password Age is set to 0 in the " & _
    "domain. Therefore, the password does not expire."
    Else
    intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
    Wscript.Echo "The maximum password age is " & intMaxPwdAge & " days"
    If intTimeInterval >= intMaxPwdAge Then
    Wscript.Echo "The password has expired."
    Else
    Wscript.Echo "The password will expire on " & _
    DateValue(dtmValue + intMaxPwdAge) & " (" & _
    int((dtmValue + intMaxPwdAge) - now) & " days from today"
    & _
    ")."
    End If
    End If
    End If

    Это не работает:-(
     
    zoid, Mar 28, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.