Re: Force PW change with notice
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/08/04
- Next message: Lisa_at_work: "Re: Index.dat files"
- Previous message: andy d: "Re: Force PW change with notice"
- In reply to: Navigato: "Force PW change with notice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 08 Oct 2004 17:07:19 +0200
Navigato wrote:
> If not, where can I find the current value of a
> user's remaining days until password expires?
Hi
A VBScript that does this (will work for local accounts, as
well as NT4 and AD domain users):
'--------------------8<----------------------
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Set objWshNet = CreateObject("WScript.Network")
' get current user domain and user name
strDomain = objWshNet.UserDomain
strUser = objWshNet.UserName
Set objUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
lngFlags = objUser.Get("userFlags")
WScript.Echo "Name: " & objUser.Name & vbCrLf _
& "FullName: " & objUser.FullName & vbCrLf
If objUser.PasswordExpired = 1 Then
WScript.Echo "User must change password at next logon"
ElseIf (lngFlags And ADS_UF_DONT_EXPIRE_PASSWD) = 0 Then
vExpireDays = DateDiff("d",Now(),CDate(objUser.PasswordExpirationDate))
WScript.Echo "Password Expiration Date: " _
& objUser.PasswordExpirationDate & vbCrLf _
& "Password expires in " & vExpireDays & " days"
Else
WScript.Echo "Password never expires"
End If
If objUser.AccountDisabled = -1 Then
WScript.Echo "User is disabled"
Else
WScript.Echo "User is not disabled"
End If
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Lisa_at_work: "Re: Index.dat files"
- Previous message: andy d: "Re: Force PW change with notice"
- In reply to: Navigato: "Force PW change with notice"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|