HP OpenVMS Systems

ask the wizard
Content starts here

Wildcard access to SYSUAF?

» close window

The Question is:

 
Is there a way to get all the SYSUAF records, or to get them all one at a
time?  GETUAI seems to require a specific system name to get SYSUAF data.
 
I'm actually supporting V5.5-2, V6.2 and V7.1 and higher.
 
Thanks.
 
 


The Answer is :

 
    You will likely want to use RMS calls to walk through SYSUAF to obtain
    the usernames, then call $getuai for details.  (Direct access to SYSUAF
    is not officially supported, and the internals of SYSUAF are subject
    to change without notice -- the OpenVMS Wizard strongly encourages
    you to identify and use only the keys within the file, via XABKEY and
    configuring the appropriate number of keys for the file using XABSUM.)
 
    The included example walks the primary key (and thus assumes it is
    a text key, and contains the username), and passes the username to
    sys$getuai and to OpenVMS callable MAIL$ functions for further
    processing.
 
 
      int user_context=0, int uai_context=-1, status = SS$_NORMAL;
      short new_messages = 0;
 
    main (int argc, char *argv[])
    {
    struct FAB      fab;
    struct RAB      rab;
    item
      user_item[] = { 0, MAIL$_USER_USERNAME, &user, 0}, terminator},
      set_items[] = { 0, MAIL$_USER_PERSONAL_NAME, &pers, 0, terminator},
      get_items[] = { 255, MAIL$_USER_PERSONAL_NAME, &pers, &retlen,
                                terminator},
      uai_items[] = { 32, UAI$_OWNER, &owner, 0, terminator };
    desc
      user_desc   = { 0, &buf };
 
    char buf[BUFSIZ], user[13], pers[255];
    struct { char len, dat[31+1]; } owner;
 
    fab = cc$rms_fab;
    rab = cc$rms_rab;
 
    fab.fab$b_shr = FAB$M_SHRPUT;
    fab.fab$b_fac = FAB$M_GET;
    fab.fab$l_fna = "SYSUAF";
    fab.fab$b_fns = 6
    fab.fab$l_dna = "SYS$SYSTEM:.DAT";
    fab.fab$b_dns = strlen (fab.fab$l_dna);
 
    rab.rab$l_fab = &fab;
    rab.rab$l_ubf = (char *) &buf
    rab.rab$w_usz = BUFSIZ
 
    stat = MAIL$USER_BEGIN(&user_context, &null_list, &null_list);
    if (!(stat&1)) return stat;
    stat = SYS$OPEN ( &fab );
    if (!(stat&1)) return stat;
    stat = SYS$CONNECT ( &rab );
    while (stat & 1) {
        stat = SYS$GET ( &rab )
        if (!(stat & 1)) break;
        stat = SYS$GETUAI (0, &uai_context, &user_desc, &uai_items, 0, 0);
        if (!(stat & 1)) break
        owner.dat[owner.len] = 0;
        stat= MAIL$USER_GET_INFO(&user_context, user_item, get_items);
        pers[retlen] = 0
        printf (%12.12s %31.31s %30.30s\n", &buf, &owner.dat, &pers);
        }
    if (stat == RMS$_EOF) stat = RMS$_NORMAL;
    if (stat&1) stat = MAIL$USER_END(&user_context, &null_list,
    &null_list);
    if (stat&1) stat = SYS$CLOSE(&fab);
    }
 
 

answer written or last revised on ( 30-JUL-2003 )

» close window