=?Utf-8?Q?_clear_the_=E2=80=98password_never_ex?= =?Utf-8?Q?pires=E2=80=99?=

=?Utf-8?Q?_clear_the_=E2=80=98password_never_ex?= =?Utf-8?Q?pires=E2=80=99?=

Post by cGluZWNvbm » Thu, 09 Oct 2008 23:57:16



Your script set the bit, I need to reset (clear the chechbox). I XORd the
flags and that seems to reset the bit. Now I can set the 'change password on
next logon'.
Bob
 
 
 

=?Utf-8?Q?_clear_the_=E2=80=98password_never_ex?= =?Utf-8?Q?pires=E2=80=99?=

Post by XFJlbV » Fri, 10 Oct 2008 07:14:01


To set the 'change password on next logon',

''''''
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Const ADS_UF_PASSWORD_EXPIRED = &H800000

sUserName = "name.."

' get computer name
Set oWshNet = CreateObject("WScript.Network" )
sComputerName = oWshNet.ComputerName

Set oUser = GetObject("WinNT://" _
& sComputerName & "/" & sUserName & ", user")

lngFlags = oUser.Get("UserFlags")

If lngFlags AND ADS_UF_DONT_EXPIRE_PASSWD Then
oUser.Put "UserFlags", lngFlags XOR ADS_UF_DONT_EXPIRE_PASSWD
oUser.SetInfo
End If

If Not lngFlags AND ADS_UF_PASSWORD_EXPIRED Then
oUser.Put "PasswordExpired", 1
oUser.SetInfo
End If
''''''

\Rems