Article 126881 of comp.os.vms:
Path: nntpd.lkg.dec.com!pa.dec.com!decuac.dec.com!haven.umd.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!usc!elroy.jpl.nasa.gov!lll-winken.llnl.gov!simtel!harbinger.cc.monash.edu.au!news.uwa.edu.au!info.curtin.edu.au!newsmaster
From: crobw@cuppa.curtin.edu.au
Newsgroups: comp.os.vms
Subject: RE: Not allowing users to log in more than once to a machine.
Date: Fri, 11 Aug 95 11:05:04 +800
Organization: Curtin University
Lines: 194
Message-ID: <40ehcq$rij@info.curtin.edu.au>
References: <rfeehan.39.00148434@atlas.ultranet.com>
NNTP-Posting-Host: alpha4.curtin.edu.au

In Article <rfeehan.39.00148434@atlas.ultranet.com>
rfeehan@atlas.ultranet.com (Robert Feehan) writes:
>With VMS (5.5-2) is there any way to keep users from logging in to the system 
>more than once. I know you can disable set host but they can still log in from 
>another terminal. 
>
>The Company I work for requires this (not sure exactly why) and our 
>programmers setup a complicated login process to so it. I would like to 
>streamline it since we lost most of the command files that did it during a 
>crash.
>

Following my .sig there is a command procedure which gleans information on a
username across the whole cluster. Invoked by a user, it lists some useful
information. However, if the impossibly stupid logical name
Curtin_Modem_Constrictor_User_Killer is defined with a non-null value the
procedure enforces a policy of allowing only one interactive session per user.
You will obviously need to use it as a basis for your desired policy - please
do not just invoke it verbatim!

In reply to Jerry Leichter's "re-engineering the business", our main reason for
doing this is to enable enough job slots for the undergraduate population.
Undergrads specifically requiring computer time as part of the set coursework
are allocated an account for that purpose. In addition, *all* students may use
a self-service account allocation to obtain an account for electronic mail. The
resulting number of simultaneous sessions can be enormous.

/Robert J Wright  Virtual Memory Systematist and Digital Command Linguist
Curtin University Computing Centre. (+61-9) 351-7385 voice (+61-9) 351-2673 fax
Kent Street, Bentley 6102, Western Australia.
GPO Box U1987, Perth 6001, Western Australia.	crobw@cc.curtin.edu.au

$ ver = f$verify(0,0)
$ trace = f$trnlnm("check-jobs-verify",,,"EXECUTIVE")
$!  THE FOLLOWING LINE IS *NOT* A COMMENT - it causes something to happen
$! 'f$verify(trace)
$! ---------------------------------------------------------------------------+
$! CHECK-JOBS.COM - Find all non-batch jobs for this user on cluster          |
$!	            If invoked from SYS$SYLOGIN, enforce policy               |
$!                  otherwise, just display info.                             |
$! ---------------------------------------------------------------------------+
$!	Placement:		sys$common:[sysmgr] (/prot=w:e)               |
$!	Original Author:        Robert J. Wright, Curtin University,          |
$!                                                Computing Centre.           |
$!	Modified By:		                                              |
$! ---------------------------------------------------------------------------+
$!                                                                            |
$! This procedure is invoked from sys$sylogin IFF the higher-level routine    |
$! requires us to logout a user with more than one non-batch job on the       |
$! cluster. In other words, sys$sylogin chooses which users to prune.         |
$! If a user chooses to invoke this procedure, we give them a useful display, |
$! but do NOT destroy their world.                                            |
$!                                                                            |
$! ----------------+-------+--------------------------------------------------+
$!   	     C H A N G E   L O G                                              |
$! ----------------+-------+--------------------------------------------------+
$!	 Date      | Name  | Description                                      |
$! ----------------+-------+--------------------------------------------------+
$!  5-May-1993     | rjw   | Created                                          |
$! ----------------+-------+--------------------------------------------------+
$! 19-Jul-1995     | rjw   | Added Process Name                               |
$! ----------------+-------+--------------------------------------------------+
$!                 |       |                                                  |
$! ----------------+-------+--------------------------------------------------+
$
$ say = "write sys$output"
$ bell[0,7] = 7
$
$!      This (user-mode) logical name only exists when sys$sylogin defines it.
$!      It is deassigned when we finish (or die...).
$!
$ if f$trnlnm("Curtin_Modem_Constrictor_User_Killer") .nes. ""
$ then
$  Kill = "True"
$  if f$mode() .eqs. "BATCH" then goto WrapUp ! if this is a batch job, it is immune.
$ else
$  Kill = "False"
$ endif
$
$ pid      = f$getjpi("", "pid")
$ username = f$getjpi("", "username")
$
$!      If in "user" mode, use P1 as username, if present
$
$ if .not. Kill
$ then
$   if p1.nes."" 
$   then
$     if f$identifier(p1, "name_to_number") .ne. 0
$     then
$       username = p1
$     else
$       say bell, bell
$       say "No such user identifier, ", p1
$       goto WrapUp
$     endif
$   endif
$ endif
$
$ ctx = ""
$ x = f$context( "process", ctx, "nodename", "*", "eql")      ! all cluster nodes 
$ x = f$context( "process", ctx, "username", username, "eql") ! this username
$ x = f$context( "process", ctx, "jobtype", "BATCH", "neq")   ! non-batch job
$ x = f$context( "process", ctx, "master_pid", pid, "neq")    ! and not this pid
$
$ Unique = "True"
$
$ prefix = "has a "
$ first = "True"
$ found = "False"
$
$Search:
$
$ pid = f$pid(ctx)
$ if pid .eqs. ""
$ then
$  goto Finish
$ else
$  found = "True"
$  unique = "False"
$  type = f$getjpi( pid, "jobtype")
$  type = f$element(type, "/", "DETACHED/NETWORK/BATCH/LOCAL/DIALUP/REMOTE")
$  node = f$getjpi( pid, "nodename")
$  ims  = f$getjpi( pid, "imagname")
$  ims  = f$parse(ims,,,"name")
$  rpid = f$getjpi( pid, "pid")
$  prcn = f$getjpi( pid, "prcnam")
$  if ims .eqs. ""
$  then
$   ims = " at DCL level "
$  else
$   ims = " running " + ims
$  endif
$  if first
$  then
$    If .not. Kill
$    Then
$      say ""
$      say "Username ", username
$    EndIf
$    first = "False"
$  endif
$  If .not. Kill
$  Then
$   say prefix, type, " job on node ", node, "(", rpid, ", ", prcn, ")", ims
$  EndIf
$  prefix = "and a "
$  goto Search
$ endif
$
$Finish:
$
$ if Unique
$ then
$  goto Final
$ else
$   if Kill
$     then
$       say bell, bell, bell
$       say "Curtin Computing Centre policy restricts you to ONE non-batch job"
$       say ""
$      logout
$    else
$      goto Final
$   endif
$ endif
$
$Final:
$
$ if (.not. found) .and. (.not. Kill)
$ then
$   say ""
$   say "Search found no non-Batch jobs for ", username
$   say ""
$ endif
$ pid  = f$getjpi("", "pid")
$ If f$edit(username,"trim") .eqs. f$edit(f$getjpi("", "username"),"trim")
$ Then
$  type = f$getjpi( pid, "jobtype")
$  type = f$element(type, "/", "DETACHED/NETWORK/BATCH/LOCAL/DIALUP/REMOTE")
$  node = f$getjpi( pid, "nodename")
$  ims  = f$getjpi( pid, "imagname")
$  ims  = f$parse(ims,,,"name")
$  rpid = f$getjpi( pid, "pid")
$  prefix = "This job is "
$  If .not. Kill
$  Then
$    say prefix, type, " job on node ", node, "(", rpid,", ",prcn, ")", ims
$  EndIf
$ EndIf
$
$WrapUp:
$
$ exit f$verify(ver)*0 + 1	


