Obtain list of users who have not logged in for x days

Discuss the Scalix Server software

Moderators: ScalixSupport, admin

tenaciousC
Posts: 89
Joined: Thu Mar 30, 2006 5:41 pm
Location: Manchester, UK.

Obtain list of users who have not logged in for x days

Postby tenaciousC » Thu Feb 21, 2008 5:04 am

Hi All,

Just wondered if anyone knew if there was a way of creating a list of users who have not logged in to the server for x days?

Main reason is to detect accounts which are no longer in use and may need to be terminated.

Thanks in advance for any ideas.

Cheers

C :D

Valerion
Scalix Star
Scalix Star
Posts: 2730
Joined: Thu Feb 26, 2004 7:40 am
Location: Johannesburg, South Africa
Contact:

Postby Valerion » Thu Feb 21, 2008 5:06 am

omshowu -n "User Name" gives you a Last Signon date and time.

tenaciousC
Posts: 89
Joined: Thu Mar 30, 2006 5:41 pm
Location: Manchester, UK.

Postby tenaciousC » Thu Feb 21, 2008 7:31 am

Valerion wrote:omshowu -n "User Name" gives you a Last Signon date and time.


Superb! Thanks.

tenaciousC
Posts: 89
Joined: Thu Mar 30, 2006 5:41 pm
Location: Manchester, UK.

Postby tenaciousC » Thu Feb 21, 2008 7:53 am

Someone might find this useful.

Code: Select all

omshowu -m all | cut -d"/" -f 1 | while read mailboxname; do echo $mailboxname"|" | tr -d '\n'; omshowu -n "$mailboxname" | grep 'Last Signon' | sed 's/Last Signon : //g'; done

mikethebike
Posts: 566
Joined: Mon Nov 28, 2005 4:16 pm
Location: England

Postby mikethebike » Thu Feb 21, 2008 11:26 am

remember that will show the last time a delegate opened the mailbox! So you could have a mailbox that is locked, and still see the date change :)

kool_kid
Posts: 179
Joined: Wed Dec 05, 2007 7:27 am

Postby kool_kid » Thu Feb 21, 2008 11:50 am

Code: Select all

#!/usr/bin/perl -w
# sxlastlog.pl - a lastlog type script for Scalix.
# Version 1.10
# Ben Tisdall 2007. ben -att- redcircleit -dott- -comm-
# TODO: Give the user the option to specify a mailnode.
# TODO: Display each Scalix user's mailnode to avoid confusion.

use strict;
my ($user,$real,%userlist,$when,$displayname,$lastlogin);
my $omshowu = "/opt/scalix/bin/omshowu";

format STDOUT_TOP =
User Name                           Last logged in
=====================================================
.

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      @<<<<<<<<<<<<<<<<
$displayname,$lastlogin
.

open (SHOWALL, "$omshowu -m all|");
while (<SHOWALL>) {
      chomp;
      $user = (split (/\//))[0];
      open (SHOWU,"$omshowu -n '$user'|");
      while (<SHOWU>) {
            chomp;
            if (/^User Name/) {
                  $real = (split(/:/))[1];
                  $real =~ s/^\s*([^\/]+)\b.+/$1/;
            }
            if (/^Last/) {
                  if (/Never/) {
                        $when = "*Never logged in*";
                  } else {
                        $when = (split)[3] . " " . (split)[4];
                  }
            $userlist{$user} = $when;
            }
      }
      close (SHOWU);
}
close (SHOWALL);
foreach $displayname (sort {lc $a cmp lc $b} (keys %userlist)) {
      $lastlogin = $userlist{$displayname};
      write (STDOUT);
}


this also does the same thing. I got it from wiki i guess.


Return to “Scalix Server”



Who is online

Users browsing this forum: No registered users and 2 guests

cron