This might be useful to steal code from, feel free to use it....
Code: Select all
// ----------------------------------------------------------------------------
// rtl_user_authorization
//
// This routine fills in a structure that holds metadata about a
// VMS user. The data comes from the SYSUAF file and is obtianed via
// a call to sys$getuai.
//
// Callers odf this routine will need either GRPPRV or SYSPRV,
// unless they have read access to SYSUAF.
//
//
// Arguments Description
// ---------------- -------------------------------------------------------
// userName address of string descriptor holding the name of the
// user to look up.
//
// userSYSUAF address of structure used to hold the metadata
//
//
// Returns Description
// ---------------- -------------------------------------------------------
// 1 Successful call
// userSYSUAF is populated with the fetched metadata.
//
// -1 Error in call, nothing returned
//
//
//
// ----------------------------------------------------------------------------
// Modification History
//
//
// Date Author Modification(s)
// ----------- ---------------- ---------------------------------------------
// 27-FEB-2019 Tim Lovern New module as of this date
//
// 28-FEB-2019 Tim Lovern Added lastLogin and lastChange2
//
//
//
//
//
//
//
//
// ----------------------------------------------------------------------------
#define __NEW_STARLET 1
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <ssdef.h>
#include <stsdef.h>
#include <iledef>
#include <uaidef.h>
#include <descrip.h>
#include <string.h>
#include <gen64def.h>
#include <starlet.h>
#include <hdf:authorize.h>
#define ITEM_COUNT 25
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
long rtl_user_authorization(DSCS *userName, TYPE_AUTHORIZE *userSYSUAF)
{
long status = 0;
static TYPE_AUTHORIZE user;
static unsigned short retLen[ITEM_COUNT];
static ILE3 itemList[] =
{
{ 32, UAI$_ACCOUNT, &user.acctName, &retLen[ 0]},
{ 32, UAI$_DEFDEV, &user.defDevice, &retLen[ 1]},
{ 64, UAI$_DEFDIR, &user.defDirect, &retLen[ 2]},
{ 8, UAI$_DEF_PRIV, &user.defPrivs, &retLen[ 3]},
{ 1, UAI$_ENCRYPT, &user.algorithm1, &retLen[ 4]},
{ 1, UAI$_ENCRYPT2, &user.algorithm2, &retLen[ 5]},
{ 8, UAI$_EXPIRATION, &user.acctExpires, &retLen[ 6]},
{ 4, UAI$_FLAGS, &user.acctFlags, &retLen[ 7]},
{ 8, UAI$_LASTLOGIN_I, &user.lastLogin, &retLen[ 8]},
{ 64, UAI$_LGICMD, &user.loginCmd, &retLen[ 9]},
{ 3, UAI$_LOCAL_ACCESS_P, &user.accTimeP, &retLen[10]},
{ 3, UAI$_LOCAL_ACCESS_S, &user.accTimeS, &retLen[11]},
{ 3, UAI$_NETWORK_ACCESS_P, &user.netAccTimeP, &retLen[12]},
{ 3, UAI$_NETWORK_ACCESS_S, &user.netAccTimeS, &retLen[13]},
{ 32, UAI$_OWNER, &user.acctOwner, &retLen[14]},
{ 1, UAI$_PRIMEDAYS, &user.primeDays, &retLen[15]},
{ 8, UAI$_PRIV, &user.acctPrivs, &retLen[16]},
{ 8, UAI$_PWD, &user.pwd1Hash, &retLen[17]},
{ 8, UAI$_PWD_DATE, &user.lastChange, &retLen[18]},
{ 4, UAI$_PWD_LENGTH, &user.pwdLength, &retLen[19]},
{ 8, UAI$_PWD2, &user.pwd2Hash, &retLen[20]},
{ 8, UAI$_PWD2_DATE, &user.lastChange2, &retLen[21]},
{ 2, UAI$_SALT, &user.pwdSalt, &retLen[22]},
{ 4, UAI$_UIC, &user.acctUIC, &retLen[23]},
{255, UAI$_USER_DATA, &user.userData, &retLen[24]},
{ 0, 0, NULL, NULL }
};
// -------------------------------------------------------
// make the call
// -------------------------------------------------------
status = sys$getuai(0,0, userName, itemList, 0, 0, 0);
if (status != SS$_NORMAL)
status = -1;
// -------------------------------------------------------
// return to the caller
// -------------------------------------------------------
memcpy(userSYSUAF, &user, sizeof(user));
return status;
}