Article 158057 of comp.os.vms:
Below is something I threw together to test the $PERSONA_ routines.
It's fairly simple and does work.  It just "changes" your personality
and does a spawn...

--------------------------------------------------------------------------
	program impersonate
	%title	"Impersonate a Username and spawn a sub-process"
	%ident	"X1-001"

!+
! Version:	X1-001
!
! Facility:	General goodies.
!
! Abstract:	Uses the $PERSONA_ routines to impersonate a valid username
!		and spawns a sub-process for you.
!
! Environment:	
!
! History:
!
!	24-May-1996, DBS; Version X1-001
! 001 -	Original version.
!-

	option type = explicit,						  &
		constant type = integer,				  &
		size = (integer long, real double)

%include "$IMPDEF"	%from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
%include "$RMSDEF"	%from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
%include "$SSDEF"	%from %library "SYS$LIBRARY:BASIC$STARLET.TLB"

	external long function	lib$get_foreign
	external long function	lib$put_output
	external long function	lib$spawn
	external long function	sys$exit
	external long function	sys$persona_assume
	external long function	sys$persona_create
	external long function	sys$persona_delete

	declare long constant	false = 0
	declare long constant	true = -1
	declare long constant	my_persona = 1

	declare string		dummy
	declare long		flags
	declare long		persona
	declare long		sstatus
	declare long		username_len
	declare string constant	username_prompt = "_who "

	map (personastuff)						  &
		string		username = 12

	sstatus = lib$get_foreign (username by desc			  &
					,username_prompt by desc	  &
					,username_len by ref)

	if (username_len = 0) then
	    sstatus = rms$_eof
	end if !(username_len = 0) then

	if (sstatus and 1) then
	    flags = 0
	    sstatus = sys$persona_create (persona by ref,		  &
						username by desc,	  &
						flags by value)
	    if ((sstatus and 1) = 0) then
		call lib$put_output ("%Sorry . . . don't know that one")
	    else
	    flags = (imp$m_assume_security or imp$m_assume_job_wide)
	    sstatus = sys$persona_assume (persona by ref,		  &
						flags by value)
	    if ((sstatus and 1) = 0) then
		call lib$put_output ("%Sorry . . . can't do that one")
	    else
	    call lib$put_output ("%Spawning . . .")
	    sstatus = lib$spawn ()

	    sstatus = sys$persona_assume (my_persona by ref,		  &
						flags by value)
	    call lib$put_output ("%Resuming my original identity . . .")

	    sstatus = sys$persona_delete (persona by ref)
	    end if !((sstatus and 1) = 0) then
	    end if !((sstatus and 1) = 0) then
	end if !(sstatus and 1) then

	call sys$exit (sstatus by value)

	end program
-------------------------------------------------------------------------

Have fun!

Dave.
-------------------------------------------------------------------------
David B Sneddon (dbs)  OpenVMS Systems Programmer  dave@online.olc.com.au
On-Line Computing,Ph +61 9 3813000,Fax 3881746  sneddo@perth.dialix.oz.au
"Life is what happens to you while you're busy making other plans" Lennon


