Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
cbspeda  
#1 Posted : Monday, July 18, 2011 11:03:06 PM(UTC)
cbspeda

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
ivan  
#2 Posted : Tuesday, July 19, 2011 12:44:09 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,123

Thanks: 9 times
Was thanked: 49 time(s) in 49 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
Users browsing this topic
Forum Jump  
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.

Powered by YAF.NET | YAF.NET © 2003-2022, Yet Another Forum.NET
This page was generated in 0.039 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.