Rank: Newbie
Groups: Registered
Joined: 12/30/2010(UTC) Posts: 3 Location: Austria
We want to delete all Email Architect User where the last login in Email Account older than 3 Month is. Is there any Solution ? Thanks Peter
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
cbspeda wrote: We want to delete all Email Architect User where the last login in Email Account older than 3 Month is. Is there any Solution ? Thanks Peter
Please copy the following to notepad
then change your password
Code:
Option Explicit
Dim host, sysuser, password, domain, user, emailaddr
host = "localhost"
sysuser = "system"
password = "systempassword"
Dim inactivedays
inactivedays = 90 '3 months no logon
domain = "*" 'seach in all domains, you can also specify the domain name to seach
Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
Const S_OK = 0
If oSvr.Connect( host, sysuser, password, 0, "127.0.0.1" ) <> S_OK Then
WScript.Echo( "connect server failed." )
WScript.Quit
End If
Dim oDomains, oDomain
Set oDomains = oSvr.DomainCollection
If domain = "*" Then
Dim i, nCount
nCount = oDomains.Count
For i = 0 To nCount-1
Set oDomain = oDomains.Items(CLng(i))
If Not (oDomain Is Nothing) Then
If oDomain.IsAlias = 0 Then
SearchDomain oDomain
End If
End If
Next
Else
Set oDomain = oDomains.Items(CStr(domain))
If Not (oDomain Is Nothing) Then
If oDomain.IsAlias = 0 Then
SearchDomain oDomain
Else
WScript.Echo "you can't search domain alias: " & domain
End If
Else
WScript.Echo "non-existed domain name: " & domain
End If
End If
WScript.Echo( "Completed" )
Sub SearchDomain( ByRef oDomain )
WScript.Echo ""
WScript.Echo "search users in domain: " & oDomain.Name
WScript.Echo ""
Dim lastLogon
Dim i, nCount, oUsers, oUser
Set oUsers = oDomain.UserCollection
Dim bDel
bDel = True
Dim arInactives
nCount = oUsers.Count
ReDim arInactives( nCount + 1 )
Dim n
n = 0
For i = 0 To nCount-1
Set oUser = oUsers.Items(CLng(i))
If Not(oUser Is Nothing) Then
If oUser.IsAlias = 0 Then
lastLogon = oUser.LastLogon
If DateDiff("d", lastLogon, Now() ) > inactivedays Then
oUser.Enabled = 0
oUser.UpdateFields
WScript.Echo oUser.Name
WScript.Echo "Last Logon:" & lastLogon
WScript.Echo "now user is disabled!"
n = n+1
arInactives(n) = oUser.Name
End If
End If
End If
Next
If bDel and n > 0 Then
For i = 1 To n
WScript.Echo arInactives(i) & " deleted!"
WScript.Echo( oUsers.Remove(arInactives(i)))
Next
End If
End Sub
then save it to deleteinactiveuser.vbs or any name with .vbs extension.
Finally, run it in DOS command with
cscript.exe "c:\my script\deleteinactiveuser.vbs"
then it is ok
Forum Jump
EmailArchitect Support
Email Component Development
- EASendMail SMTP Component - .NET Version
- EASendMail SMTP Component - Windows Store Apps
- EASendMail SMTP ActiveX Object
- EAGetMail POP3 & IMAP4 Component - .NET Version
- EAGetMail POP3 & IMAP4 ActiveX Object
Exchange Server and IIS SMTP Plugin
- DomanKeys/DKIM for Exchange Server and IIS SMTP
- Disclaimer and S/MIME for Exchange Server and IIS
EmailArchitect Email Server
- EmailArchitect Email Server (General)
- EmailArchitect Email Server Development
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.