S
Sudeep
Hi ,
I have a script to find number of days left for password expiry and send email using CDONTS.
Now I need to run this on a web page ,that is it will search for a user in Active Directory and display the number of days left for his password to expire.
The script is as follows :-
On Error Resume Next
Const SEC_IN_DAY = 86400
Set objLDAP = GetObject ("LDAP://OU=OEuser,DC=ibpoil,DC=com")
For each obj in objLDAP
Set objuserLDAP = GetObject ("LDAP://CN=" & obj.cn & ",OU=OEuser,DC=ibpoil,DC=com")
dtmValue = objUserLDAP.PasswordLastChanged
intTimeInterval = int(now - dtmValue)
wscript.echo "Message Sent before NT Object"
Set objDomainNT = GetObject("WinNT://ibpoil")
intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")
intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
intnoofdaysleft = int((dtmValue + intMaxPwdAge) - now)
If intnoofdaysleft <= 30 Then
wscript.echo intnoofdaysleft
Set myMail = CreateObject("CDONTS.NewMail")
myMail.From="(e-mail address removed)"
myMail.To=objUserLDAP.userPrincipalName
myMail.Subject="Password Expiry Notice"
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body= "The password for user " & objuserLDAP.cn & " will expire on " & DateValue(dtmValue + intMaxPwdAge) & " (" & int((dtmValue + intMaxPwdAge) - now) & " days from today.) To change the password please click on the link." & " http://202.144.61.155/iisadmpwd/ " & " "
myMail.Send
wscript.echo "Message Sent"
End If
Next
Hope someone can help me out.
regards,
Sudeep Batra.
I have a script to find number of days left for password expiry and send email using CDONTS.
Now I need to run this on a web page ,that is it will search for a user in Active Directory and display the number of days left for his password to expire.
The script is as follows :-
On Error Resume Next
Const SEC_IN_DAY = 86400
Set objLDAP = GetObject ("LDAP://OU=OEuser,DC=ibpoil,DC=com")
For each obj in objLDAP
Set objuserLDAP = GetObject ("LDAP://CN=" & obj.cn & ",OU=OEuser,DC=ibpoil,DC=com")
dtmValue = objUserLDAP.PasswordLastChanged
intTimeInterval = int(now - dtmValue)
wscript.echo "Message Sent before NT Object"
Set objDomainNT = GetObject("WinNT://ibpoil")
intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")
intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
intnoofdaysleft = int((dtmValue + intMaxPwdAge) - now)
If intnoofdaysleft <= 30 Then
wscript.echo intnoofdaysleft
Set myMail = CreateObject("CDONTS.NewMail")
myMail.From="(e-mail address removed)"
myMail.To=objUserLDAP.userPrincipalName
myMail.Subject="Password Expiry Notice"
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body= "The password for user " & objuserLDAP.cn & " will expire on " & DateValue(dtmValue + intMaxPwdAge) & " (" & int((dtmValue + intMaxPwdAge) - now) & " days from today.) To change the password please click on the link." & " http://202.144.61.155/iisadmpwd/ " & " "
myMail.Send
wscript.echo "Message Sent"
End If
Next
Hope someone can help me out.
regards,
Sudeep Batra.