[comp.os.vms] ID_HOLDER.COM

WARNOCK@prism.clemson.EDU (Todd Warnock) (08/05/87)

I received many requests for my ID_HOLDER program.  Here it is !
Good luck - Any improvements, suggestions for improvements, 
will be much appreciated !


Todd Warnock
VAX Systems
Clemson University
Clemson, South Carolina 29634-2803

ARPA:	Warnock@Prism.Clemson.EDU
BITnet:	Warnock@Clemson
CSnet:	Warnock@Clemson.CSnet
......................... Cut between dotted lines and save ....................
$!..............................................................................
$!
$! VAX/VMS archive file created by VMS_SHAR Version:'09-Jun-1987'
$! Copyright (c) 1987, by Michael Bednarek
$! To unpack, simply execute (@) the file.
$! This archive was created by WARNOCK
$!      on Wednesday 5-AUG-1987 14:40:01.33
$! It contains the following file(s):
$! BUILD.COM CHECK_ID.FOR ID_HOLDER.CLD ID_HOLDER.DOC ID_HOLDER.FOR
$! ID_HOLDER.HLP UAIDEF.MAR
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1:Open/Write Out 'File_is
$ Open/Read In VMS_SHAR_DUMMY.DUMMY
$Next_Record: Read/End_Of_File=EOF In Record
$ Write Out F$Extract(1,255,Record)
$ Goto Next_Record
$EOF: Close Out
$ Close In
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2:Return
$Start:
$ File_is="BUILD.COM"
$ Check_Sum_is=1785278623
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ set noon
X$ fortran id_holder
X$ fortran check_id
X$ macro uaidef
X$ link id_holder,check_id,uaidef
X$ set command id_holder
$ GoSub Convert_File
$ File_is="CHECK_ID.FOR"
$ Check_Sum_is=980227321
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X	subroutine CHECK_ID(username,identifier,return_status)
X!+
X! Version:	1-001
X!
X! Facility:	System Management Library
X!
X! Abstract:	This module determines whether or not a username holds
X!		a given identifier.
X!
X! Environment:	User Mode, privileged (requires access to SYSUAF/RIGHTSLIST)
X!
X! Author:	Todd Warnock
X!		VAX Systems
X!		Clemson University
X!		Clemson, South Carolina 29634-2803
X!
X!		ARPA:	Warnock@Prism.Clemson.EDU
X!		BITnet:	Warnock@Clemson
X!		CSnet:	Warnock@Clemson.CSnet
X! Modified By:
X! 1-0001	- Original.  01-Jun-1987
X!
X!-
Xc
X	implicit integer*4	(a-z)
Xc
X	include '($rmsdef)'		
X	include '($jpidef)'
Xc
X       	external uai$_uic
X	external ss$_nosuchid
Xc
X	integer*4	status
X	integer*4	return_status
X	character*23	identifier 
X	integer*4	identifier_len
X	integer*4	id_num
X	character*23	id_name
X	integer*4	id_len
X	character*12	username
X	integer*4	uic
X	integer*4	uic_len
X	integer*4	holder(2)
X	integer*4	context /0/
X	logical		have /.false./
Xc
Xc SETUP the $GETUAI item list
Xc
X	structure/getuai_item/
X	union
X		map
X			integer*2	buffer_len
X			integer*2	item_code
X			integer*4	buffer_addr
X			integer*4	ret_len_addr
X		end map
X		map
X			integer*4	end_list/0/
X		end map
X	end union
X	end structure
X
X	record /getuai_item/ item_list(2)
Xc
Xc Define the item(s) (terminator is defined above)
Xc
X	item_list(1).item_code = %loc(uai$_uic)
X	item_list(1).buffer_len = 4
X	item_list(1).buffer_addr = %loc(uic)
X	item_list(1).ret_len_addr = %loc(uic_len)
Xc
Xc Trim the identifier
Xc
X	status = str$trim(identifier,identifier,identifier_len)
Xc
Xc Call $GETUAI
Xc	
X	status = sys$getuai(,,%descr(username),
X     +		%ref(item_list),,,)
X	if (status .eq. rms$_rnf) goto 888
X	if (.not.status) goto 888
Xc
X	holder(1) = uic
X	holder(2) = 0
Xc
X10	status=sys$find_held(%ref(holder),%ref(id_num),,%ref(context))
X	if (.not.status) then
X	   goto 888
X	else
X	   status=sys$idtoasc(%val(id_num),id_len,id_name,,,)	
X	   if (.not.status) goto 888
X	   if (id_name(1:id_len).eq.identifier(1:identifier_len))goto 888
X	endif
X	goto 10
Xc
X888	return_status = status
X	status = sys$finish_rdb(%ref(context))
X	return
X	end
$ GoSub Convert_File
$ File_is="ID_HOLDER.CLD"
$ Check_Sum_is=1951482661
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X!
X!	ID_HOLDER 
X!
Xdefine verb ID_HOLDER
X	image ID_HOLDER
X	parameter P1,label=USERNAME,prompt="Username",
X		value(required)
X	qualifier IDENTIFIER,default,nonnegatable,
X		value(required)
X	qualifier SYMBOL,default,nonnegatable,
X		value(required)
$ GoSub Convert_File
$ File_is="ID_HOLDER.DOC"
$ Check_Sum_is=845089757
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
XID_HOLDER - Returns TRUE or FALSE in a symbols depending on whether or not a 
X		user holds a given identifier.
X
XThe following programs (images) are part of ID_HOLDER:
X
X	ID_HOLDER.FOR		source to ID_HOLDER
X	UAIDEF.MAR		$GETUAI definitions
X	CHECK_ID.FOR		source to check if user holds an identifier
X	ID_HOLDER.HLP		ID_HOLDER help file
X	ID_HOLDER.DOC		this file
X	ID_HOLDER.CLD		the ID_HOLDER command definition
X
XTo build ID_HOLDER:
X
X	$ for ID_HOLDER
X	$ for CHECK_ID
X	$ macro UAIDEF
X	$ link ID_HOLDER,CHECK_ID,UAIDEF
X	$ set command ID_HOLDER
X
XThe following steps are used to install ID_HOLDER in the SYS$COMMON:[SYSEXE]
Xdirectory (to make it accessible from all cluster nodes.)
XID_HOLDER must be installed with SYSPRV privilege to provide information on
Xother users.
X
X	$backup/log id_holder.exe;0 sys$common:[sysexe]id_holder.exe;0
X	$set prot=(w:e) sys$common:[sysexe]id_holder.exe
X	$install
X	add/open/head/share/priv=sysprv sys$common:[sysexe]id_holder
X	exit
X
XThe image must be INSTALLed each time the system boots, so it should be
Xplaced in the system startup file for each cluster node.  Also, the command 
Xmust be added to the DCL tables (or used on a process basis).
X
X	$ set def sys$library
X	$ set command id_holder /tables=dcltables/output=dcltables
X
XNote:  If the image ID_HOLDER is put anywhere OTHER than SYS$SYSTEM, the
Xfile ID_HOLDER.CLD will have to be modified to reflect the location of the
Ximage.  (DEFINE IMAGE where$it$lives:ID_HOLDER)
$ GoSub Convert_File
$ File_is="ID_HOLDER.FOR"
$ Check_Sum_is=1816073725
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X	program ID_HOLDER
X!+
X! Version:	1-001
X!
X! Facility:	System Management Library
X!
X! Abstract:	This module is called to return information as to whether
X!		or not a user has a given identifier.
X!		If yes, a value of "TRUE" is returned in the symbol
X!		specified on the DCL line, else the value "FALSE" is returned.
X!
X! Environment:	User Mode.
X!
X! Author:	Todd Warnock
X!		VAX Systems
X!		Clemson University
X!		Clemson, South Carolina 29634-2803
X!
X!		ARPA:	Warnock@Prism.Clemson.EDU
X!		BITnet:	Warnock@Clemson
X!		CSnet:	Warnock@Clemson.CSnet
X! Modified By:
X! 1-0001	- Original.  Jun-29-1887
X!
X!-
X        implicit integer*4 (A-Z)
Xc
Xc Include the necessary definitions
Xc
X        include 	'($jpidef)'
X	external	ss$_nosuchid
Xc
Xc  Define the variables
Xc
X	character*12	username
X	character*55	symbol
X	character*55	identifier
X	integer*4	id_len
Xc
Xc  Get the symbol name from the CLI 
Xc
X	status = cli$get_value('SYMBOL',symbol)
X	if (.not. status) call lib$stop (%val(status))
Xc
Xc  Get the username from the CLI 
Xc
X	status = cli$get_value('USERNAME',username)
X	if (.not. status) call lib$stop (%val(status))
Xc
Xc  Get the identifier from the CLI 
Xc
X	status = cli$get_value('IDENTIFIER',identifier,id_len)
X	if (.not. status) call lib$stop (%val(status))
Xc
Xc Check and see if you have the identifier identifier
Xc
X	call check_id(username,identifier(1:id_len),status)
X	if (.not.status) then
X           status=lib$set_symbol(symbol,'FALSE',)
X	else
X           status=lib$set_symbol(symbol,'TRUE',)
X	endif
X        if (.not. status) call lib$stop (%val(status))
X  	end
$ GoSub Convert_File
$ File_is="ID_HOLDER.HLP"
$ Check_Sum_is=1866152346
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X1 ID_HOLDER
XID_HOLDER is a utility available on the VAX/VMS systems that allows
Xusers to determine if a given user holds a given identifier.  If the
Xuser holds the identifier, a value of "TRUE" is returned in the
Xspecified symbol.  If the user does not hold the identifier, a value of
X"FALSE" is returned in the specified symbol.
X
XFormat:
X
X	ID_HOLDER username [qualifiers]
X2 Parameters
Xusername
X 
XThe username that you are inquiring about.
X
X2 Command_Qualifiers
X
X/IDENTIFIER
X /IDENTIFIER=identifier
X
XSpecifies the identifier that you wish to know if the user holds.
XIf the user does not hold the identifier, or if the identifier
Xdoesn't exist, a value of "FALSE" is returned in the symbol.
X
X/SYMBOL
X /SYMBOL=symbol
XSpecifies the symbols in which to return TRUE or FALSE, depending on
Xwhether or not the indentifier exists.
X
X2 Examples   
X
X	$ ID_HOLDER/IDENTIFIER=IBM_SYSTEMS/SYMBOL=USER_IDENT JOEUSER
X	$ SH SYM USER_IDENT
X	  X = "TRUE"
X
X	
X In this example, userid JOEUSER holds the identifier IBM_SYSTEMS.
$ GoSub Convert_File
$ File_is="UAIDEF.MAR"
$ Check_Sum_is=102303317
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X	$UAIDEF	GLOBAL
X	.END
$ GoSub Convert_File