(go to: table of contents, index, list of vms_sys, prev: GETTIM, next: GETUTC)
vms_sys.getuai() does _not_ raise an exception when the SYS$GETUAI routine
returns an error. You must check 'status' in the dictionary that is returned.
Format:
It is only put into the dictionary, when SYS$GETUAI returns a success status.
It is only put into the dictionary, when SYS$GETUAI returns a success status.
A 'counted ASCII string' (ASCIC) - which means that the first byte contains
the string length - is returned as a normal string (one without the count byte
at the beginning). You can use Python's len() function to find out how long
the returned string is.
After the call to SYS$GETUAI the modified value is returned in the 'dict'
object under the key 'contxt'. Feed this value into the 'contxt' argument
for the next call to vms_sys.getuai().
Note: the contxt argument is only useful for repeated access to _the same_
username! SYS$GETUAI does not provide any wildcard access over all usernames
in the user authorization file (UAF).
The pyvms.uaf_get_usernames()
function can be used to get a list of all usernames that are stored in the UAF.
It is possible to put an item tuple - e. g.: ('UAI$_ACCOUNT',None) - instead
of a single string - e. g.: 'UAI$_ACCOUNT' -, but this is not required for
output-only items.
According to the OpenVMS V6.1 documentation on which the implementation is
based SYS$GETUAI does not take any input items. If the programmer specifies
one, the behaviour is unpredictable!
Examples:
GETUAI - Get User Authorization Information
Returns authorization information about a specified user.
29-DEC-1998 ZE.
dict = vms_lib.getuai (None, [contxt], usrnam, itmlst \
[,None] [,None] [,None])
Returns:
Arguments:
Note that the 'data' that is returned can itself be a tuple for some items
- see below.
special notes about some item codes:
UAF> add GETUAI_TST /owner= "PYVMS-getuai-TEST" -
/uic= [12345,13524] /account= "PYVMS_GT" -
/cli= "CLI_TEST" /clitables= "DCLTABLES_TEST" -
/lgicmd= "LGICMD_TEST" -
/flags= (dismail, disuser, restrict) -
/privileges= (noALL, TMPMBX) /defprivileges= (noALL, TMPMBX)
UAF> modify GETUAI_TST -
/device= "DEFDEV_TEST" /directory= [DEFDIRTEST]
UAF> modify GETUAI_TST -
/interactive /batch /network
UAF> modify GETUAI_TST /primedays= (noSATURDAY, noSUNDAY) -
/expiration= "29-FEB-2000 12:34:56.78" /pwdminimum= 12 -
/pwdlifetime= "12-21:43:56.87"
UAF> modify GETUAI_TST /maxjobs= 11 /maxacctjobs= 12 /prclm= 13 -
/priority= 14 /queprio= 15 /cputime= "11-22:33:44.55" -
/fillm= 111 /shrfillm= 112 /biolm= 113 /diolm= 114 -
/astlm= 115 /tqelm= 116 /enqlm= 117
UAF> modify GETUAI_TST /bytlm= 1111 /pbytlm= 1112 /jtquota= 1113 -
/wsdefault= 1114 /wsquota= 1115 /wsextent= 1116 -
/pgflquota= 1117 /password= XYZ
UAF> modify GETUAI_TST /local= -
(PRIMARY, 1-3,7,12-15, SECONDARY, 1-8,9,11,17-21,23)
UAF> modify GETUAI_TST /network= -
(PRIMARY, 1,3,5,7,9,11,13,15,17,19,21,23, -
SECONDARY, 0,2,4,6,8,10,12,14,16,18,20,22)
UAF> show GETUAI_TST
Username: GETUAI_TST Owner: PYVMS-getuai-TEST
Account: PYVMS_GT UIC: [12345,13524] ([PYVMS_GT,GETUAI_TST])
CLI: CLI_TEST Tables: DCLTABLES_TEST
Default: DEFDEV_TEST:[DEFDIRTEST]
LGICMD: LGICMD_TEST
Flags: DefCLI Restricted DisUser DisMail
Primary days: Mon Tue Wed Thu Fri
Secondary days: Sat Sun
Primary 000000000011111111112222 Secondary 000000000011111111112222
Day Hours 012345678901234567890123 Day Hours 012345678901234567890123
Network: -#-#-#-#-#-#-#-#-#-#-#-# #-#-#-#-#-#-#-#-#-#-#-#-
Batch: ##### Full access ###### ##### Full access ######
Local: -###---#----####-------- -#########-#-----#####-#
Dialup: ##### Full access ###### ##### Full access ######
Remote: ##### Full access ###### ##### Full access ######
Expiration: 29-FEB-2000 12:34 Pwdminimum: 12 Login Fails: 0
Pwdlifetime: 12 21:43 Pwdchange: (pre-expired)
Last Login: (none) (interactive), (none) (non-interactive)
Maxjobs: 11 Fillm: 111 Bytlm: 1111
Maxacctjobs: 12 Shrfillm: 112 Pbytlm: 1112
Maxdetach: 0 BIOlm: 113 JTquota: 1113
Prclm: 13 DIOlm: 114 WSdef: 1114
Prio: 14 ASTlm: 115 WSquo: 1115
Queprio: 15 TQElm: 116 WSextent: 1116
CPU: 11 22:33:44 Enqlm: 117 Pgflquo: 1117
Authorized Privileges:
TMPMBX
Default Privileges:
TMPMBX
UAF>
>>> import vms_sys
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST',('UAI$_OWNER',))
>>> # even a single item-code must be passed as a tuple -------^
>>> type (dict)
<type 'dictionary'>
>>> dict
{'UAI$_OWNER': 'PYVMS-getuai-TEST', 'status': 1}
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST', \
... ('UAI$_OWNER', 'UAI$_EXPIRATION'))
>>> returned_items = dict.items()
>>> returned_items.sort()
>>> for itm in range(len(returned_items)):
... print returned_items[itm]
...
('UAI$_EXPIRATION', 44585444967800000L)
('UAI$_OWNER', 'PYVMS-getuai-TEST')
('status', 1)
>>>
>>> q_expdat = dict.get('UAI$_EXPIRATION')
>>> q_expdat
44585444967800000L
>>> type (q_expdat)
<type 'long int'>
>>> vms_sys.asctim (q_expdat)
'29-FEB-2000 12:34:56.78'
>>>
>>> # UAI$_CPUTIM is expressed in 10ms steps
>>> # this example shows how to make this into a delta-time
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST',('UAI$_CPUTIM',))
>>> # even a single item-code must be passed as a tuple --------^
>>> l_cputim = dict.get('UAI$_CPUTIM')
>>> # convert 10ms ticks into 100ns ticks
>>> q_cputim = l_cputim * 100000L
>>> # a delta-time must be negative
>>> q_cputim = -q_cputim
>>> # show ASCII representation
>>> vms_sys.asctim (q_cputim)
' 11 22:33:44.55'
>>>
>>> # this example shows how to deal with access 'times'
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST', \
... ('UAI$_LOCAL_ACCESS_P', 'UAI$_LOCAL_ACCESS_S' ))
>>> returned_items = dict.items()
>>> returned_items.sort()
>>> for itm in range(len(returned_items)):
... print returned_items[itm]
...
('UAI$_LOCAL_ACCESS_P', (113, 15, 255))
('UAI$_LOCAL_ACCESS_S', (1, 244, 65))
('status', 1)
>>>
>>> ba_local_access_s = dict.get ('UAI$_LOCAL_ACCESS_S')
>>> ba_local_access_s
(1, 244, 65)
>>> l_local_access_s = \
... ba_local_access_s[0] + (ba_local_access_s[1]*256) + \
... ba_local_access_s[2] * 65536
>>> l_local_access_s
4322305
>>> hex (l_local_access_s)
'0x41f401'
>>>
Primary 000000000011111111112222 Secondary 000000000011111111112222
Day Hours 012345678901234567890123 Day Hours 012345678901234567890123
Local: -###---#----####-------- -#########-#-----#####-#
^
!---- this is the least significant bit
reverse: #-## ###- ---- #-## #### ###-
-4-- ---1 8421 -4-- ---- ---1
| | | | | |
4 1 f 4 0 1
>>> # get lots of items
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST',
... ('UAI$_ACCOUNT' ,'UAI$_ASTLM'
... ,'UAI$_BATCH_ACCESS_P' ,'UAI$_BATCH_ACCESS_S'
... ,'UAI$_BIOLM' ,'UAI$_BYTLM'
... ,'UAI$_CLITABLES' ,'UAI$_CPUTIM'
... ,'UAI$_DEFCLI' ,'UAI$_DEFDEV'
... ,'UAI$_DEFDIR' ,'UAI$_DEF_PRIV'
... ,'UAI$_DFWSCNT' ,'UAI$_DIALUP_ACCESS_P'
... ,'UAI$_DIALUP_ACCESS_S' ,'UAI$_DIOLM'
... ,'UAI$_ENCRYPT' ,'UAI$_ENCRYPT2'
... ,'UAI$_ENQLM' ,'UAI$_EXPIRATION'
... ,'UAI$_FILLM' ,'UAI$_FLAGS'
... ,'UAI$_GRP' ,'UAI$_JTQUOTA'
... ,'UAI$_LASTLOGIN_I' ,'UAI$_LASTLOGIN_N'
... ,'UAI$_LGICMD' ,'UAI$_LOCAL_ACCESS_P'
... ,'UAI$_LOCAL_ACCESS_S' ,'UAI$_LOGFAILS'
... ,'UAI$_MAXACCTJOBS' ,'UAI$_MAXDETACH'
... ,'UAI$_MAXJOBS' ,'UAI$_MEM'
... ,'UAI$_NETWORK_ACCESS_P' ,'UAI$_NETWORK_ACCESS_S'
... ,'UAI$_OWNER' ,'UAI$_PBYTLM'
... ,'UAI$_PGFLQUOTA' ,'UAI$_PRCCNT'
... ,'UAI$_PRI' ,'UAI$_PRIMEDAYS'
... ,'UAI$_PRIV' ,'UAI$_PWD'
... ,'UAI$_PWD2' ,'UAI$_PWD2_DATE'
... ,'UAI$_PWD_DATE' ,'UAI$_PWD_LENGTH'
... ,'UAI$_PWD_LIFETIME' ,'UAI$_QUEPRI'
... ,'UAI$_REMOTE_ACCESS_P' ,'UAI$_REMOTE_ACCESS_S'
... ,'UAI$_SALT' ,'UAI$_SHRFILLM'
... ,'UAI$_TQCNT' ,'UAI$_UIC'
... ,'UAI$_USERNAME' ,'UAI$_USER_DATA'
... ,'UAI$_WSEXTENT' ,'UAI$_WSQUOTA'
... ))
>>>
>>> returned_items = dict.items()
>>> returned_items.sort()
>>> for itm in range(len(returned_items)):
... print returned_items[itm]
...
('UAI$_ACCOUNT', 'PYVMS_GT ')
('UAI$_ASTLM', 115)
('UAI$_BATCH_ACCESS_P', (0, 0, 0))
('UAI$_BATCH_ACCESS_S', (0, 0, 0))
('UAI$_BIOLM', 113)
('UAI$_BYTLM', 1111)
('UAI$_CLITABLES', 'DCLTABLES_TEST')
('UAI$_CPUTIM', 103162455)
('UAI$_DEFCLI', 'CLI_TEST')
('UAI$_DEFDEV', 'DEFDEV_TEST:')
('UAI$_DEFDIR', '[DEFDIRTEST]')
('UAI$_DEF_PRIV', 32768L)
('UAI$_DFWSCNT', 1114)
('UAI$_DIALUP_ACCESS_P', (0, 0, 0))
('UAI$_DIALUP_ACCESS_S', (0, 0, 0))
('UAI$_DIOLM', 114)
('UAI$_ENCRYPT', 3)
('UAI$_ENCRYPT2', 0)
('UAI$_ENQLM', 117)
('UAI$_EXPIRATION', 44585444967800000L)
('UAI$_FILLM', 111)
('UAI$_FLAGS', 154)
('UAI$_GRP', 5349)
('UAI$_JTQUOTA', 1113)
('UAI$_LASTLOGIN_I', 0L)
('UAI$_LASTLOGIN_N', 0L)
('UAI$_LGICMD', 'LGICMD_TEST')
('UAI$_LOCAL_ACCESS_P', (113, 15, 255))
('UAI$_LOCAL_ACCESS_S', (1, 244, 65))
('UAI$_LOGFAILS', 0)
('UAI$_MAXACCTJOBS', 12)
('UAI$_MAXDETACH', 0)
('UAI$_MAXJOBS', 11)
('UAI$_MEM', 5972)
('UAI$_NETWORK_ACCESS_P', (85, 85, 85))
('UAI$_NETWORK_ACCESS_S', (170, 170, 170))
('UAI$_OWNER', 'PYVMS-getuai-TEST')
('UAI$_PBYTLM', 1112)
('UAI$_PGFLQUOTA', 1117)
('UAI$_PRCCNT', 13)
('UAI$_PRI', 14)
('UAI$_PRIMEDAYS', 96)
('UAI$_PRIV', 32768L) # @@ construct an example with
('UAI$_PWD', -3994283066824042557L) # @@ module vms_prvdef
('UAI$_PWD2', 0L)
('UAI$_PWD2_DATE', 0L)
('UAI$_PWD_DATE', -1L)
('UAI$_PWD_LENGTH', 12)
('UAI$_PWD_LIFETIME', -11150368700000L)
('UAI$_QUEPRI', 15)
('UAI$_REMOTE_ACCESS_P', (0, 0, 0))
('UAI$_REMOTE_ACCESS_S', (0, 0, 0))
('UAI$_SALT', 29702)
('UAI$_SHRFILLM', 112)
('UAI$_TQCNT', 116)
('UAI$_UIC', 350558036)
('UAI$_USERNAME', 'GETUAI_TST ')
('UAI$_USER_DATA', '')
('UAI$_WSEXTENT', 1116)
('UAI$_WSQUOTA', 1115)
('status', 1)
>>>
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST',
... ('UAI$_EXPIRATION'
... ,'UAI$_LASTLOGIN_I'
... ,'UAI$_LASTLOGIN_N'
... ,'UAI$_PWD_DATE'
... ,'UAI$_PWD2_DATE'
... ,'UAI$_PWD_LIFETIME'
... ))
>>>
>>> for key in dict.keys():
... if (key != 'status'):
... print key, vms_sys.asctim (dict.get(key))
...
UAI$_EXPIRATION 29-FEB-2000 12:34:56.78
UAI$_LASTLOGIN_I 17-NOV-1858 00:00:00.00 <-- no login, yet
UAI$_PWD2_DATE 17-NOV-1858 00:00:00.00
UAI$_PWD_DATE 0 00:00:00.00
UAI$_PWD_LIFETIME 12 21:43:56.87
UAI$_LASTLOGIN_N 17-NOV-1858 00:00:00.00
>>>
>>> # UIC of username
>>> dict = vms_sys.getuai (None,None,'GETUAI_TST',
... ('UAI$_GRP','UAI$_MEM'))
>>> w_grp = dict.get('UAI$_GRP')
>>> w_mem = dict.get('UAI$_MEM')
>>> # oct() puts a '0' in front - [1:] removes this
>>> t_uic = '[' + oct(w_grp)[1:] + ',' + oct(w_mem)[1:] + ']'
>>> t_uic
'[12345,13524]'
>>>
>>> # calculate date of next password expiration
>>> # 'dict' is from a different account
>>> dict = vms_sys.getuai (None,None,'NOPRIV',
... ('UAI$_PWD_DATE','UAI$_PWD_LIFETIME'))
>>> q_expdate = dict.get('UAI$_PWD_DATE') + \
... dict.get('UAI$_PWD_LIFETIME')
>>> vms_sys.asctim (dict.get('UAI$_PWD_DATE'))
'25-SEP-1998 20:10:42.78'
>>> vms_sys.asctim (dict.get('UAI$_PWD_LIFETIME'))
' 30 00:00:00.00'
>>> vms_sys.asctim (q_expdate)
'26-AUG-1998 20:10:42.78'
>>>
>>> # try access to a non-existent username
>>> dict = vms_sys.getuai (None,None,'NO_USER',('UAI$_FILLM',))
>>> l_status = dict.get('status')
>>> l_status
98994
>>>
>>> vms_sys.getmsg (l_status)[0]
'%RMS-E-RNF, record not found'
>>>
$!+
$! make a report which user has a FILLM quota is too small
$!-
$ type USERLIST.DAT
DEFAULT
SYSTEM
NO_SUCHUSR
FIELD
ZESSIN
$
$ type CHK_FILLM.PY
import vms_sys
#
min_fillm = 250 # UAI$_FILLM must be >= 250
#
u_file = open ('USERLIST.DAT','r')
u_lines = u_file.readlines()
u_file.close()
# remove trailing NEWLINE
for line_number in range (len (u_lines)):
u_lines[line_number] = u_lines[line_number][:-1]
#
# check all users from list
for line_number in range (len (u_lines)):
username = u_lines[line_number]
dict = vms_sys.getuai (None,None,username,('UAI$_FILLM',))
l_status = dict.get('status')
if (l_status != 1): # 1 = SS$_NORMAL
print 'failed to read UAF record for',\
username, ', status=', l_status
else:
w_fillm = dict.get('UAI$_FILLM')
if (w_fillm < 250):
print 'FILLM =', w_fillm, 'too small for user', \
username
#
#
#
$ python CHK_FILLM.PY
FILLM = 20 too small for user DEFAULT
failed to read UAF record for NO_SUCHUSR , status= 98994
FILLM = 100 too small for user FIELD
$! !
$ write sys$output f$message (98994) ! <-------------^
%RMS-E-RNF, record not found
$
>>> # username is a string ----------v
>>> dict = vms_sys.getuai (None,None,1,('UAI$_FILLM',))
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: argument 3: expected read-only buffer, int found
>>> # that means 'string' ------^^^^^^^^^
>>> # even a single item-code must be passed as a tuple ----v
>>> dict = vms_sys.getuai (None,None,'NO_USER',('UAI$_FILLM'))
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: argument 4: itmlst - must be a tuple of strings
>>>
>>> dict = vms_sys.getuai (None,None,'NO_USER',('UAI$_BAD-ITM',))
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: itmlst - unknown FAC$_ item code
>>>
>>> # 'item-code' must be string ---------------v
>>> dict = vms_sys.getuai (None,None,'NO_USER',(1,))
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: argument 4: tuple-element:n item-code for output-item\
must be a string
>>>
(go to: table of contents,
index,
list of vms_sys,
prev: GETTIM,
next: GETUTC)