Audit log: Login-Success.txt Report (last time accessed)

Discussions on webmail and the Professional version.
Post Reply
solucionmike
Posts: 116
Joined: Sat Dec 10, 2005 6:37 pm
Location: Mexico
Contact:

Audit log: Login-Success.txt Report (last time accessed)

Post by solucionmike »

Hi,
I have Version 10.31 ME Professional.

I am trying to get a report listing the last the time mail boxes was accessed successfully (authenticated) to check which accounts are no longer is use.
In MailEnableAdmin->Under Servers->Localhost->Properties->Auditing Record times for last login activity is checked (and has been for many months).

When i checked the file (Login-Success.txt which was empty) on a few of the accounts, the last modified date seems to be updated OK.
Example: D:\Program Files (x86)\Mail Enable\Config\Postoffices\Domain.com\MAILBOXES\AccountName\Login-Success.txt

I am looking for a report to show last time accessed using the date/time of the file for all MailBoxes.

I noticed in a forum topic:
https://www.mailenable.com/forum/viewtopic.php?f=8&t=42849
Which suggests someone (a user?) has developed this type of report for Version 10
I am unsure if this is secure/authentic and if it even works.
Is there a Report recommended by MailEnable I can use? Or some one who has used this one.

Thanks
Mike
Mike May

Admin
Site Admin
Posts: 1127
Joined: Mon Jun 10, 2002 6:31 pm
Location: Melbourne, Victoria, Australia

Re: Audit log: Login-Success.txt Report (last time accessed)

Post by Admin »

The following VBScript will do this, although the time will be in UTC. It needs to be run as 32bit. i.e.

c:\windows\syswow64\cscript.exe showlogins.vbs example.com

Code: Select all

dim sPostoffice

Set iArgs=WScript.Arguments
If iArgs.Count > 1 Then
        WScript.Echo "Usage: Showlastlogin [postoffice]"
        WScript.Echo "Shows last login date."
        WScript.Quit(1)
else
	if iArgs.Count=1 then
		sPostoffice = iArgs(0)
	else
		sPostoffice = ""
	end if

End If

        Set oLogin = WScript.CreateObject("MEAOAU.Login")

	oLogin.UserName = ""
	oLogin.Password = ""
	oLogin.Account = sPostoffice
	oLogin.Rights = ""
	oLogin.Description = ""
	oLogin.Status = -1

	If (oLogin.FindFirstLogin() = 1) Then
       		Do
			if oLogin.LastSuccessfulLogin = 0 then
				WScript.Echo oLogin.UserName & chr(9) & "Not recorded"
			else
				WScript.Echo oLogin.UserName & chr(9) & oLogin.LastSuccessfulLogin & chr(9) & DateAdd("s",oLogin.LastSuccessfulLogin,#1970/1/1#)

			end if
			
			oLogin.UserName = ""
			oLogin.Password = ""
			oLogin.Account = sPostoffice
			oLogin.Rights = ""
			oLogin.Description = ""
			oLogin.Status = -1
                Loop While (oLogin.FindNextLogin() = 1)
        End If

	Set oLogin=Nothing

WScript.Quit(0)
With the current beta for 10.33 (at https://www.mailenable.com/beta), we added the last login setting to the Powershell feature, so you can do this following script with it. This only works in 64bit, but it shows the time as local time. Save it, and execute under Powershell with:

showlogins.ps1 -postoffice example.com

Code: Select all

 param (
    [Parameter(Mandatory=$true)][string]$postoffice
 )

# Ensure the snapin module is loaded (if it is not already)
if ((Get-PSSnapin -Name MailEnable.Provision.Command -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PsSnapin MailEnable.Provision.Command
}

# Get the list of mailboxes in the postoffice
$lstMailboxes = Get-MailEnableMailbox -Postoffice $postoffice
ForEach($oMailbox in $lstMailboxes)
{

    $lastlogin = Get-MailEnableMailbox -Postoffice $postoffice -Mailbox $oMailbox.MailboxName -Setting "mailboxLastLogin"
    Write-Host $oMailbox.MailboxName -NoNewline
    if (0 -eq $lastlogin)
    {
       Write-Output "`tNot recorded"
    }
    else
    {
        $converted = ([datetime]'1/1/1970Z').AddSeconds($lastlogin)
        Write-Host "`t" -NoNewline
        Write-Output $converted.ToLocalTime().ToString('s')
    }
}

solucionmike
Posts: 116
Joined: Sat Dec 10, 2005 6:37 pm
Location: Mexico
Contact:

Re: Audit log: Login-Success.txt Report (last time accessed)

Post by solucionmike »

Thanks so much!
I used the 32 bit option and worked great.
Mike
Mike May

Post Reply