1753916 Members
8146 Online
108810 Solutions
New Discussion юеВ

DCL to find last logon

 
SOLVED
Go to solution
HarrinG
Advisor

DCL to find last logon

Is there a way using a DCL query to find the Last Logon for a user? I want to have a process that runs and looks for users who have not logged onto the system within 90 days and DISUSER them. Unfortunatly, where I work occasionally users are discharged and IS is not notified. I have not found anything on the usual site that would help me.

I am running OVMS 7.3-2 on an Alpha.
10 REPLIES 10
Steven Schweda
Honored Contributor

Re: DCL to find last logon

Popular topic, it seems. Anything here look
useful?:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1155072
Ken Robinson
Valued Contributor

Re: DCL to find last logon

Download the freeware program called SCANUAF. It can be downloaded from <>

This program will be able to tell you who hasn't logged in withing the last 90 days. Make sure you read the instructions. The syntax is weird in places.
Hein van den Heuvel
Honored Contributor

Re: DCL to find last logon

Second time today.. for a much similar question.

I had some code handy for that task.
Check out below.

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting



$!
$! uaf_lastlogin.com Hein van den Heuvel,August 2007.
$
$! List records from SYSUAF for which the Last Interactive Login is more
$! than 90 days ago.
$
$cutoff_date = f$cvtime("TODAY -90-")
$!libr/extr=$uafdef/out=uafdef.tmp sys$library:lib.mlb
$!sea uafdef.tmp flag...
$!EQU UAF$Q_PWD_DATE 380
$!EQU UAF$Q_LASTLOGIN_I 396
$!EQU UAF$L_FLAGS 468
$!EQU UAF$V_DISACNT 4
$
$define sysuaf sys$disk:[]sysuaf.dat ! Local copy for testting
$sysuaf = f$parse("SYSUAF","SYS$SYSTEM:.DAT",,,"SYNTAX_ONLY")
$open /read/share=write uaf 'sysuaf'
$loop:
$ read/end=done uaf rec
$ lastlogin_bin = F$EXTR(380,8,rec)
$ lastlogin_asc = F$FAO("!%D",f$cvui(32,32,f$fao("!AD",8,lastlogin_bin)))
$ IF f$cvtime(lastlogin_asc) .GTS. cutoff_date THEN GOTO loop
$ IF f$cvsi(468*8+4,1,rec) THEN GOTO loop ! disuser already?
$ IF.NOT.f$cvsi(32,32,lastlogin_bin) THEN lastlogin_asc = "Never!"
$ WRITE SYS$OUTPUT "MODIFY ''username' /FLAG=DISUSEER ! Last Login: ", lastlogin_asc
$ GOTO loop
$done:
$close uaf
Hein van den Heuvel
Honored Contributor

Re: DCL to find last logon

Ooops, missed a somewhat essential line just before the $WRITE:

$ username = F$EXTRACT(4,12,rec)

Hein.
Hein van den Heuvel
Honored Contributor

Re: DCL to find last logon

Arghh....

$ lastlogin_bin = F$EXTR(380,8,rec)
should be:

$ lastlogin_bin = F$EXTR(396,8,rec)

[ If a moderator comes by and would be willing to clean up my mess... that woudl be great ]

New script:

$!
$! uaf_lastlogin.com Hein van den Heuvel,August 2007.
$
$! List records from SYSUAF for which the Last Interactive Login is more
$! than 'p1' days ago (default 90).
$
$IF p1.eqs."" THEN p1 = "90"
$cutoff_date = f$cvtime("TODAY -''p1'-")
$!libr/extr=$uafdef/out=uafdef.tmp sys$library:lib.mlb
$!sea uafdef.tmp flag...
$!EQU UAF$Q_LASTLOGIN_I 396
$!EQU UAF$L_FLAGS 468
$!EQU UAF$V_DISACNT 4
$
$define sysuaf sys$disk:[]sysuaf.dat ! Local copy for testting
$sysuaf = f$parse("SYSUAF","SYS$SYSTEM:.DAT",,,"SYNTAX_ONLY")
$open /read/share=write uaf 'sysuaf'
$loop:
$ read/end=done uaf rec
$ lastlogin_bin = F$EXTR(396,8,rec)
$ lastlogin_asc = F$FAO("!%D",f$cvui(32,32,f$fao("!AD",8,lastlogin_bin)))
$ IF f$cvtime(lastlogin_asc) .GTS. cutoff_date THEN GOTO loop
$ IF f$cvsi(468*8+4,1,rec) THEN GOTO loop ! disuser already?
$ username = F$EXTRACT(4,12,rec)
$ WRITE SYS$OUTPUT "MODIFY ''username' /FLAG=DISUSEER ! Last Login: ", lastlogin_asc
$ GOTO loop
$done:
$close uaf


Graham Burley
Frequent Advisor

Re: DCL to find last logon

You ought to check the last non-interactive login (UAF$Q_LASTLOGIN_N) too.

I'd use READ/NOLOCK in case the script bombs.
The Brit
Honored Contributor

Re: DCL to find last logon

Here is a DCL script (rename to *.com) I have been using for over 10 years. Works for me, and could certainly be modified for you. Contains a lot of comments which you should read.

Dave.
The Brit
Honored Contributor
Solution

Re: DCL to find last logon

Sorry about that, I posted the whole folder.

Here is the script.

By the way, the folder contains examples of associated files, and the "REMOVE" script.

Dave.

The Brit
Honored Contributor

Re: DCL to find last logon

I am having a bad day here. It looks like the file I attached opens in "notepad", i.e. the no CR/LF.

Try pulling the script "INACTIVE.TXT" from the ZIP file on my first post, and open with WORDPAD.

Dave.