RE: List Password Expire date on AD
- From: freddy <freddy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Jul 2006 12:23:02 -0700
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?
- Follow-Ups:
- References:
- RE: List Password Expire date on AD
- From: freddy
- RE: List Password Expire date on AD
- From: B
- RE: List Password Expire date on AD
- Prev by Date: Re: capture return value from Web
- Next by Date: RE: List Password Expire date on AD
- Previous by thread: RE: List Password Expire date on AD
- Next by thread: RE: List Password Expire date on AD
- Index(es):
Relevant Pages
|