[comp.os.vms] Removing old VMSmail records

sherman%v70nl.DECnet@NUSC.ARPA ("V70NL::SHERMAN") (12/09/87)

In response to:

> We found an interesting little 'feature' of VMS Mail yesterday:
> User "AAA" had his mail forwarded (using SET FORWARD) to user
> "BBB".  Well, last week we removed user AAA from the SYSUAF file,
> only to discover we could still send mail to AAA, and it
> did in fact end up in BBB's mailbox.   Presuming
> this is because running AUTHORIZE to remove a user does *not*
> update the VMSMAIL.DAT file, we would like to know if someone can
> suggest a procedure which will get our VMSMAIL.DAT  file in
> synch with our current SYSUAF file.    I wonder how many 'ghost'
> usernames are still receiving mail this way?
> 
> 
> Stephen J. Siblock

I provide the following command procedure.  The usual disclaimers
and provisos apply.

+------------------------------------------------------------------------------+
| ARPANET:  sherman@nusc.arpa           USPS:  Bill Sherman                    |
| AT&T:     (203) 440-6210                     Naval Underwater Systems Center |
|                                              MIS/OA/WP Group, Code 334       |
|                                              Building 28, Room 200           |
|                                              New London, CT  06320           |
+------------------------------------------------------------------------------+
|   "A real friend is someone who takes a winter vacation on a sun-drenched    |
|   beach, and doesn't send a card."                                           |
|                                                        - Farmer's Almanac    |
+------------------------------------------------------------------------------+

$--- cut hereabouts ------------------------------------------------------------
$	v = 'f$verify(0)
$	set noon
$	prevprivs = f$setprv("SYSPRV,EXQUOTA")
$	if .not. f$privilege("SYSPRV,EXQUOTA") then exit 36
$!
$!   PURGE_VMSMAIL.COM
$!
$!   This command procedure removes all users who are in vmsmail.dat,
$!   but not in sysuaf.dat, unless they have a forwarding address.
$!
$!   By Bill Sherman, 03-JUL-1985.
$!
$!   Last modified 03-JUL-1985.
$!
$	on control_y then goto close_up
$	on severe then goto close_up
$!
$	open/share/read/write	mail	sys$system:vmsmail.dat
$	open/share/read		uaf	sys$system:sysuaf.dat
$!
$loop:
$	read/end=eof mail record
$	username = f$edit(f$extract(0,31,record), "COLLAPSE")
$	read/nolock/error=nosuch/key="''username'" uaf dummy
$	goto loop
$nosuch:
$	addr_length = f$cvui(67*8,8,record)
$	address = f$extract(68,255,record)
$	address := 'address'
$	forward = f$extract(0,addr_length,address)
$	if forward .eqs. "" then goto no_forward
$	write sys$output "Leaving  ''username' (forwards to ''forward')"
$	goto loop
$no_forward:
$	write sys$output "Deleting ''username'"
$	read/key="''username'"/delete mail record
$	goto loop
$!
$close_up:
$	write sys$output "Aborting and closing files..."
$eof:	close mail
$	close uaf
$	v = f$verify(v)
------