Re: Force PW change with notice

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/08/04


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


Relevant Pages

  • Script (s) to help with file security audit
    ... I need to do a few things as part of our file security audit (we will be ... to return the path and file name as separate items rather than one long ... - Get a list of all domain users along with their AD location. ... I do have some limited experience with scripting and have already scripted ...
    (microsoft.public.scripting.vbscript)
  • Re: Full access without Administrative rights
    ... Administrators group to let all domain users automatically be local ... avoid the issue with cross network admin rights ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.group_policy)
  • Re: Full access without Administrative rights
    ... Administrators group to let all domain users automatically be local ... avoid the issue with cross network admin rights ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.security)
  • Re: distinguish between local or domain account?
    ... > (both local and domain accounts), but I'm trying to figure out how to ... > determine whether they are local or domain users. ... > I tried adding a '.domain' to the objGroup but it is not recognized. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.wmi)
  • Re: Remove Users From Local Admin Group
    ... > local Admin group from the login script. ... Both local and domain users will be removed ... ' account from the Administrators group will fail. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.scripting.vbscript)

Quantcast