RE: List Password Expire date on AD



User name is notemp?

"B" wrote:

Const SEC_IN_DAY = 86400
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

Set objUserLDAP = GetObject _
("LDAP://CN=notemp,OU=Users,OU=NY,OU=AM,OU=SHS,DC=bb,DC=com";)
intCurrentValue = objUserLDAP.Get("userAccountControl")

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

"freddy" wrote:

please post wait you have

"B" wrote:

Freddy,
Thank you very much for your prompt reply. I copied and modified as you
said and again received error (32, 1) Microsoft VBScript compilation error :
Expected Statement. I ran it from Primary Domain Controller (W2K3 Advanced)
Can you help me?

"freddy" wrote:

Look at this script

Const SEC_IN_DAY = 86400
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

Set objUserLDAP = GetObject _
("LDAP://CN=wp16288,OU=Users,OU=cam,OU=im,DC=nam,DC=nsroot,DC=net";)
intCurrentValue = objUserLDAP.Get("userAccountControl")

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

***Note: change the ldap:// to your server setting in
Set objUserLDAP = GetObject _
("LDAP://CN=wp16288,OU=Users,OU=cam,OU=im,DC=nam,DC=nsroot,DC=net";)
intCurrentValue = objUserLDAP.Get("userAccountControl")******

you can also read from a text file and have it loop


"B" wrote:

In Active Directory, I would like to create a script to list user's account
password expire date. I looked at this web site
(http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true),
and ran from Primary Domain Controller. Then I received error message on
line 4, saying "A referral was returned from the server". Can somebody help?
.



Relevant Pages

  • RE: List Password Expire date on AD
    ... "freddy" wrote: ... Set objUserLDAP = GetObject _ ... Wscript.Echo "The password does not expire." ... If intMaxPwdAge < 0 Then ...
    (microsoft.public.scripting.vbscript)
  • RE: List Password Expire date on AD
    ... Set objUserLDAP = GetObject _ ... Wscript.Echo "The password does not expire." ... If intMaxPwdAge < 0 Then ...
    (microsoft.public.scripting.vbscript)
  • RE: List Password Expire date on AD
    ... WScript.Echo "The password does not expire." ... dtmValue = objUser.PasswordLastChanged ... Set objUserLDAP = GetObject _ ... If intMaxPwdAge < 0 Then ...
    (microsoft.public.scripting.vbscript)
  • RE: List Password Expire date on AD
    ... WScript.Echo "The password does not expire." ... dtmValue = objUser.PasswordLastChanged ... Set objUserLDAP = GetObject _ ... If intMaxPwdAge < 0 Then ...
    (microsoft.public.scripting.vbscript)
  • Re: Help With Password Last Changed
    ... password to expire in 1 day and everyone but my test user was set to ... to have the passwords expire after 90 days. ... dtmValue = objUserLDAP.PasswordLastChanged ... This is the script I was using. ...
    (microsoft.public.windows.server.active_directory)