Need to suspend inactive users.
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Need to suspend inactive users.
I am loking for a script to suspend inactive users. Do you know a way?
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
Define "suspend".
Define "inactive".
Alsoif they are 'inactive', what is the point in suspending them?!
(Guidance can then be given when the above is clarified).
Define "inactive".
Alsoif they are 'inactive', what is the point in suspending them?!
(Guidance can then be given when the above is clarified).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
Sometimes, some company employees leave their work and company does not inform us so their mailbox keeps open. And It eats disk space by spam mails. Also could be used by viruses to send bulk mails which ends up in RBL.
I want to automacitly suspend not active users lets say those havent logged in for 90 days.
I want to automacitly suspend not active users lets say those havent logged in for 90 days.
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
See this script: viewtopic.php?p=186628#p186628 and use it as a starter. This simply rejects incoming emails to that account.
IF you REALLY want to 'remove' the account without actually removing it, you could simply rename the account instead (append "OLD" to the end of it or something similar). Remember, though, that this isnt the best idea as I believe HMS then effectively has to go through and copy all existing emails to a new 'accountOLD' folder (its not clever enough to simply do a rename of the account folder itself). And depending on how many or how big those emials are it could take considerable time and resources (including temporarily doubling its disk requirements during the process).
IF you REALLY want to 'remove' the account without actually removing it, you could simply rename the account instead (append "OLD" to the end of it or something similar). Remember, though, that this isnt the best idea as I believe HMS then effectively has to go through and copy all existing emails to a new 'accountOLD' folder (its not clever enough to simply do a rename of the account folder itself). And depending on how many or how big those emials are it could take considerable time and resources (including temporarily doubling its disk requirements during the process).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
Actually I need to disable that account to disallow smtp auth.
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
So you can simply just 'disable' it then. That will result in connections attempts to deliver in of 'account not active' and "SENT: 535 Authentication failed" for attempts to send with authentication.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
How do I automa this with script?
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
You need a standalone script that authenticates to the HMS object and is run, I would say, once a day by Task Scheduler.
Script help: https://www.hmailserver.com/documentati ... ce_scripts
Script help: https://www.hmailserver.com/documentati ... ce_scripts
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
I have no idea about these sciprting. I was looking for a ready go script. I found one but that does not seems to work. viewtopic.php?t=24235
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
Put this in a notepad file. Save as "Disactivate.vbs" (or whatever you want to call it). Change the password (HMPassword). Call it by Task Scheduler.
You can modify the line 'wscript' to include whatever information you want (and remove the leading apostrophe) and it will then output to whatever output destination (log file or screen) you have at time of running. (You can run this script interactively if you want).
Warning: it goes through ALL accounts on ALL domains.
Code: Select all
option explicit
Dim HMPassword, x, y, diffDays, oApp, oDomain, oAccount
HMPassword = "secretpassword"
Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator", HMPassword )
For x = 0 To oApp.Domains.Count - 1
Set oDomain = oApp.Domains.Item(x)
If oDomain.Active Then
For y = 0 To oDomain.Accounts.Count - 1
Set oAccount = oDomain.Accounts.Item(y)
If oAccount.Active Then
diffDays = DateDiff("d", oAccount.LastLogonTime, Now) ' get the difference in DAYS
' wscript.echo "Account=" & oAccount.address & ", oAccount.LastLogonTime=" & oAccount.LastLogonTime & ", diffdays=" & diffDays
If diffDays > 90 Then ' 90 days since last logon
oAccount.Active = False
oAccount.save
End if
End If
Next
End If
Next
Warning: it goes through ALL accounts on ALL domains.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
You know what! Thanks a lot. This will really help me lot. I tested it and it works as expected. Lately I am fighting lots of spam issue because of client based viruses those steals users password.
I really thank you. I hope last login time is trustable value.
I really thank you. I hope last login time is trustable value.
- jimimaseye
- Moderator
- Posts: 10053
- Joined: 2011-09-08 17:48
Re: Need to suspend inactive users.
Of course, the problem is that if there is a spambot using a stolen password to send out spam emails, then that 'last login' will always be renewed. So there's a chance that you are only disabling TRULY inactive accounts that are not sending spam or being a problem, and not disabling the ones that are. You would be better tackling the problem by looking at what accounts are causing the problem (been compromised) and getting their passwords changed or made inactive.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829
-
- Senior user
- Posts: 268
- Joined: 2010-11-19 18:50
Re: Need to suspend inactive users.
Yes you are right. I will keep that in mind. Thanks again.