The Question is:
How can I return the final UIC member-number from a group. I need to create
admin menus for a support team, and adding a new user would be so much easier
if I could get hold of this number.
The Answer is :
There is no built-in function for finding a spare UIC. That said,
if you impose your own standards and procedures on UIC allocation, you
can make things quite easy for yourself.
For example, assume that all usernames will have an identifier. Further
assume that all account authorization will be done through a single command
procedure that you control.
To make things simple, you can always leave an identifier at the next
UIC value to be used. Suppose the group is [201,*] called ADMIN, you can
create an identifier ADMINNEXT. Initially you create the identifier thus:
$ MCR AUTHORIZE ADD/IDENTIFIER/VALUE=UIC:[201,1] ADMINNEXT
When you want to create a new username, first translate ADMINNEXT to
find the UIC to use:
Now, before creating the new user, update your identifier value for the
$ MCR AUTHORIZE MODIFY/IDENTIFIER ADMINNEXT -
You can now use the symbol NextUIC to for the new user, having freed up
the identifier value by moving ADMINNEXT to the next slot.
o The above does not attempt to handle rollover of the member number.
When it reaches 177777, the code will (attempt to) define a group
identifier and will fail.
o There is no synchronization - if two users attempt to create a new
account simultaneously there are timing windows in which they will both
obtain the same UIC. If this is an issue, use a file as a lock.
If you're in a less cooperative environment, but can at least assume that
all usernames have an identifier, you can do a linear search for a UIC
$ IF p1.EQS."" THEN INQUIRE p1 "Group number"
$ IF p2.EQS."" THEN p2=1
$ ON WARNING THEN GOTO BadFormat
$ uicval=(grp * %X10000) + mem
$ IF F$IDENTIFIER(uicval,"NUMBER_TO_NAME").NES."" THEN GOTO loop
$ !WRITE SYS$OUTPUT "Next free UIC ''TheUIC'"
$ WRITE SYS$OUTPUT "UIC group and member numbers must be specified in OCTAL"
$ WRITE SYS$OUTPUT "Valid digits are 0-7"
If you're not concerned about contiguity of allocated UICs, you can use
any scheme to generate potential member numbers (random number generator?)
and just check if an identifier exists.
Or you can use an external database (simple RMS file) to store and
retrieve the desired information.
The OpenVMS Wizard would also recommend not ever deleting usernames, as
this makes it far easier to track the ownership of objects over time,
and as it avoids the access control and email problems that can occur
with identifier or username reallocation. Simply mark the deleted
usernames with the DISUSER flag, and leave them in SYSUAF and RIGHTSLIST.