Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Password Expiring Email Notification

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2166
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Password Expiring Email Notification
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Password Expiring Email Notification - 2/24/2005 2:09:26 PM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
I am trying to come up with someway to setup automatic email notification of expiring Windows passwords. I tried to use the script below but cannot get it to work. I know nothing about writing scripts so I was hoping somebody here might be able to tell me why it will not work. I am running this script on a Win2K domain controller(test) and my Windows domain is testdom. I copied this to a text file and saved it with a .vbs extension. I also have SMTP installed on the same domain controller. Also, do I have to enter information about the SMTP server in the script? Any help would be really appreciated.

On Error Resume Next
Const SEC_IN_DAY = 86400
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "Administrator@testdom.com"


objEmail.Textbody = "Your password is going to expire"

Set objDomain = GetObject("WinNT://testdom.com,domain")
objDomain.Filter = Array("User")

For Each objUser In objDomain
If not(isnull(objuser.FullName) or objuser.FullName = "") THEN
Set objUserLDAP = GetObject("LDAP://CN=" & objuser.FullName & ",CN=Users,DC=domainname,DC=com")
intCurrentValue = objUserLDAP.Get("userAccountControl")
If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then
'Account does not expire
Else
dtmValue = objUserLDAP.PasswordLastChanged
intTimeInterval = int(now - dtmValue)
intMaxPwdAge = 180 ' NUMBER OF DAYS A PASSWORD IS GOOD FOR
daystoexpire = int((dtmValue + intMaxPwdAge) - now)
If (daystoexpire < 6) AND (daystoexpire > 0) Then
User = objUser.FullName
Email = objUserLDAP.Mail
objEmail.Subject = "Your Network Password will expire in " & daystoexpire & " days."
If Email <> "" Then
objEmail.To = Email
objEmail.Send
End If
End If
End If
End If
Next
 
 
Post #: 1
 
 Re: Password Expiring Email Notification - 2/24/2005 2:50:06 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Which part of it didn't work ? and at what line ?

(in reply to sman)
 
 
Post #: 2
 
 Re: Password Expiring Email Notification - 2/25/2005 11:31:13 AM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
I don't get a error message. I messed around with it all day today and I think the problem might be with my setup. Below is a simple script that I was trying just to test the email function. It gives me the following error.
Line: 1
Char: 1
Error: Object required:'Server'
Code: 800A01A8
Source: Microsoft VBScript runtime error

Set objEmail = Server.CreateObject("CDONTS.NewMail")
objEmail.send "your_name@siteaddressr.com", "recipent_address@theirsiteaddress.com", "Hi-ho!", _
"Hi! I sent this e-mail from an ASP page!! --- Me"
Set objEmail = nothing


Do I have to do anything to my server for CDONTS to work? I know my SMTP server works because I can send emails through Outlook. Thanks.

(in reply to sman)
 
 
Post #: 3
 
 Re: Password Expiring Email Notification - 2/25/2005 2:42:23 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If the script isn't run from within an ASP page, you don't need the server part before CreateObject.

(in reply to sman)
 
 
Post #: 4
 
 Re: Password Expiring Email Notification - 2/25/2005 2:50:12 PM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
I am just double clicking on the .vbs file. I will change it to

Set objEmail = CreateObject("CDONTS.NewMail")
objEmail.send "your_name@siteaddressr.com", "recipent_address@theirsiteaddress.com", "Hi-ho!", _
"Hi! I sent this e-mail from an ASP page!! --- Me"
Set objEmail = nothing


Thanks

(in reply to sman)
 
 
Post #: 5
 
 Re: Password Expiring Email Notification - 2/25/2005 3:15:52 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
http://www.activexperts.com/activemail/

http://www.paulsadowski.com/WSH/cdo.htm

(in reply to sman)
 
 
Post #: 6
 
 Re: Password Expiring Email Notification - 2/25/2005 5:52:44 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
2 weeks before the PW expires in the 2k domain, the users is being confronted with the every day question: Your password will expire in # days, would you like to change it now? [YES/NO]

it's a setting, and it works, because users tend to throw mail away or read and forget about it

[8)]

(in reply to sman)
 
 
Post #: 7
 
 Re: Password Expiring Email Notification - 2/25/2005 6:01:29 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Completely agreed, I don't believe sending an email to users 0-5 days before their password is going to expire is going to make any difference. After all, do you intend to run the script everyday or so to check every single user in the domain whether their password is going to expire soon ? Of course, it could be run from a logon script, but why go through all the trouble when the OS itself can be used to do the same thing ? Maybe it's the weekend :P

(in reply to sman)
 
 
Post #: 8
 
 Re: Password Expiring Email Notification - 2/25/2005 9:45:53 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
bored people tend to invent the wheel all over

(in reply to sman)
 
 
Post #: 9
 
 Re: Password Expiring Email Notification - 2/26/2005 6:38:23 AM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
The Windows setting only works for users who are logging in to the domain. The reason I need a script is for remote users who do not log into the domain so they never get the password will expire message. Once I get the script to work I can schedule it to run nightly automatically.

(in reply to sman)
 
 
Post #: 10
 
 Re: Password Expiring Email Notification - 2/26/2005 6:45:53 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
So you dont have your remote users authenticating through the domain. Is This Ras, VPN, They just login to you without authenticating. Are the using a token, dongle, to access?

(in reply to sman)
 
 
Post #: 11
 
 Re: Password Expiring Email Notification - 2/26/2005 6:50:05 AM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
They log in through a VPN. Also, I have users whose workstations are not in the domain. They just connect to the server to access data files.

(in reply to sman)
 
 
Post #: 12
 
 Re: Password Expiring Email Notification - 2/26/2005 7:00:32 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Did you check out the links I posted? Are VPN Still uses authentication through domain.

(in reply to sman)
 
 
Post #: 13
 
 Re: Password Expiring Email Notification - 2/26/2005 7:07:59 AM   
  sman

 

Posts: 9
Score: 0
Joined: 2/24/2005
From:
Status: offline
Yes I looked at the links you posted. Thanks but the email part is working now. I edited the script like token suggested and then the email function did work. Now I am trying to edit the script so it just searches the active directory and gives me the information on the screen. I figure if I get that to work then I can put the 2 pieces together. Thanks again.

(in reply to sman)
 
 
Post #: 14
 
 Re: Password Expiring Email Notification - 2/26/2005 7:19:13 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If you could post the error message you got and the line #, others might be able to help you out.

(in reply to sman)
 
 
Post #: 15
 
 Re: Password Expiring Email Notification - 2/26/2005 11:11:20 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
wow you must have open access to that server, kewl....
though VPN works thru authentication...

(in reply to sman)
 
 
Post #: 16
 
 Re: Password Expiring Email Notification - 2/26/2005 3:43:49 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Personally, I think any kind of password expiration *notification* is ignored by most people unless they MUST change the password in order for them to logon on (personally I changed 3 days before, but the notification starts 14 days before according to GPO). Grant that, it's a somewhat good idea to have users change their password before expired, but they eventually have to. In my opnion, process and identify thousands of users' account every single day is a waste of resource (but that's just me), needless to say the bandwidth and space required for emails; like Snipah have said, people tend to ignore those emails just because it's not yet the time. :)

(in reply to sman)
 
 
Post #: 17
 
 Re: Password Expiring Email Notification - 2/27/2005 2:48:59 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Agree. Are users just keep clicking on no until last day. End users do not like changing there password and then if your using a password policy where it has to be 8 charcters long and include 3 of 4 characters, such as Caps,lowercase,numbers,symbols, then they always wait till the last day.

(in reply to sman)
 
 
Post #: 18
 
 Re: Password Expiring Email Notification - 2/27/2005 6:48:19 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Don't we all love end-users? If we didn't have them, we wouldn't have problems with PC's at all.

(most likely, we wouldn't even had a job then)


(in reply to sman)
 
 
Post #: 19
 
 Re: Password Expiring Email Notification - 2/27/2005 10:40:32 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Your right, I Bitch on a daily basis about Dumb *ss end users but if they new what they were doing alot of us would be out of work.

(in reply to sman)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Password Expiring Email Notification Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts