Page 1 of 1
Obtain list of users who have not logged in for x days
Posted: Thu Feb 21, 2008 5:04 am
by tenaciousC
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

Posted: Thu Feb 21, 2008 5:06 am
by Valerion
omshowu -n "User Name" gives you a Last Signon date and time.
Posted: Thu Feb 21, 2008 7:31 am
by tenaciousC
Valerion wrote:omshowu -n "User Name" gives you a Last Signon date and time.
Superb! Thanks.
Posted: Thu Feb 21, 2008 7:53 am
by tenaciousC
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
Posted: Thu Feb 21, 2008 11:26 am
by mikethebike
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

Posted: Thu Feb 21, 2008 11:50 am
by kool_kid
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.