|
|
|
| 17 May 2002 | LastLogged() |
| Author | Kent Dyer (dyerkb@myrealbox.com) |
| Action | Show users that have not logged in 30 days. |
| Syntax | LastLogged ("DOMAIN") -or- LastLogged (@DOMAIN) -or- LastLogged () |
| Parameters | |
| Remarks | List all users on the domain: http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=002703 - Thanks Bryce! Users that have not logged on in 30 days: http://cwashington.netreach.net/depo/view.asp?Index=323&ScriptType=vbscript Create Loginlog: http://infocenter.cramsession.com/TechLibrary/GetHtml.asp?ID=721&GetDes=&CatID=293 |
| Returns | Writes to screen / Writes to log file |
| Dependencies | Kixtart 4.x, Active Directory, DateMath(), SerialDate() |
| Examples | LastLogged(yourserver.yourdomain.com) LastLogged() |
| Source |
FUNCTION LastLogged ($domain)
$domain=GetObject("WinNT://@domain")
IF @error <> 0
EXIT(1)
ENDIF
FOR EACH $thing IN $domain
IF $thing.class = "USER"
$chklast=$thing.lastlogin ; ChkLast is used to determine the last logon time.
;IF ($chklast > (DateMath(@date,-30)) OR $chklast = "" ) AND $thing.userflags <> 661103 AND $thing.userflags <> 515
IF ($chklast < datemath(@date,-30)) OR $chklast = ""
;IF $chklast = ""
;IF $thing.lastlogin <> ""
? $thing.name
$result=SetConsole('show')
$logshare="D:\!kix"
IF ($chklast = "")
$logdata=$thing.name+Chr(13)+Chr(10)
ELSE
$logdata=$thing.name+","+$thing.lastlogin+Chr(13)+Chr(10)
ENDIF
$logfile=$logshare+'\HaveLogged.csv'
;-- Log the user into a file
$result=0
$n=0
DO
$result=Open(1, $logfile, 5)
IF ($result <> 0)
IF ($n = 0)
;First wait
? "Please wait"
ELSE
;follow waits
"."
ENDIF
SLEEP 3
ELSE
$result=WriteLine(1, $logdata)
$result=Close(1)
ENDIF
$n=$n+1
UNTIL ($result = 0) OR ($n = 5)
;ENDIF
ENDIF
ENDIF
NEXT
ENDFUNCTION ; - LastLogged -
|
|
|
|