(LOGO.JPG) Python for OpenVMS

This example finds and reports usernames that have the same UIC value using the interface to SYS$GETUAI. Access to the SYSUAF requires system privileges. Note that the example contains only minimal error checking and reporting.


#$% FIND_DUPLICATE_UICS.PY
# -----

import pyvms, sys, vms_sys

RMS__EOF = 98938

uaf_dict = pyvms.uaf_get_usernames ()

l_sts = uaf_dict ["sts"]
if (l_sts != RMS__EOF):
  l_stv = uaf_dict ["stv"]
  print vms_sys.getmsg (l_sts)[0]
  print vms_sys.getmsg (l_stv)[0]
  sys.exit(1)

uaf_list = uaf_dict ["usernames"]
# print uaf_list

uic_dict = {}
empty_list = []

for username in uaf_list:
  uai_dict = vms_sys.getuai (None,None,username, \
                         ("UAI$_OWNER", "UAI$_UIC"))
  l_status = uai_dict ["status"]
  if (l_status != 1):
    print vms_sys.getmsg (l_status)[0]
    sys.exit(1)
  t_uai_owner = uai_dict ["UAI$_OWNER"]
  l_uai_uic   = uai_dict ["UAI$_UIC"]

  if (not uic_dict.has_key (l_uai_uic)):
    usrnam_list = empty_list + [(username,t_uai_owner)] # make new list object
    uic_dict[l_uai_uic] = usrnam_list
  else:
    usrnam_list = uic_dict [l_uai_uic]
    usrnam_list.append ((username,t_uai_owner))

# print uic_dict

for uic_val in uic_dict.keys():
  usrnam_list = uic_dict [uic_val]
  if (len (usrnam_list) >= 2):
    print "duplicate UIC: [%o,%o]" % ((uic_val/65536), (uic_val%65536))
    try:
      nam, resid, attrib, ctx = vms_sys.idtoasc (uic_val)
      print "  Identifier=", nam
    except:
      # ignore ANY error in this simple example
      pass
    for idx in range (len(usrnam_list)):
      print "  ", usrnam_list[idx]

# -----
#%$


Example run:

$ python FIND_DUPLICATE_UICS.PY
duplicate UIC: [37767,1]
  Identifier= WWW_SERVER
   ('HTTP_SERVER', 'WWW-Server')
   ('WWW_SERVER', 'WWW-Server')
duplicate UIC: [1,7]
  Identifier= SYSTEST
   ('SYSTEST', 'SYSTEST-UETP')
   ('SYSTEST_CLIG', 'SYSTEST-UETP')
duplicate UIC: [10040,11]
  Identifier= ZESSIN
   ('ZESSIN', 'Zessin_Uwe')
   ('ZESSIN_2', 'Zessin_Uwe')
duplicate UIC: [123,123]
   ('NOPRIV', '')
   ('NOPRIV2', '')
$
There was no identifer for UIC [123,123].


(go to: table of contents, index)

30-OCT-1999 ZE.