Article 130384 of comp.os.vms:
Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!caen!news.eecs.umich.edu!panix!tinman.dev.prodigy.com!prodigy.com!newsjunkie.ans.net!howland.reston.ans.net!swrinde!tank.news.pipex.net!pipex!news.mathworks.com!news.ultranet.com!news.sprintlink.net!usenet.kornet.nm.kr!ames!niven.ksc.nasa.gov!usenet
From: Lee Ewertz <Lee_D._Ewertz_at_KSC__NSLD@rockwell.ksc.nasa.gov>
Newsgroups: comp.os.vms
Subject: Re: VMS password checking?
Date: 27 Sep 1995 21:22:31 GMT
Organization: NASA, Kennedy Space Center, Payload Operations
Lines: 105
Message-ID: <44cfan$svb@niven.ksc.nasa.gov>
References: <44bkqn$rro$1@mhadf.production.compuserve.com>
NNTP-Posting-Host: 192.112.239.200

Todd M. Meadows <73671.1504@CompuServe.COM> wrote:
>
> Is there a way to compare a typed in password to the actual user password?
> This will be done by a priv account.  I am trying to create a program to
> validate WWW users access to certain pages pased on VMS account and they
> won't be logged in at the time.
We have a server program that checks users password. It took my engineer
about a week to get this to work.

This is part of a program that checks if the entered password equals
the UAF password. The system services SYS$GETUAI and SYS$HASH_PASSWORD
can be found in the SYSTEM SERVICES MANUAL.



/******************************************************************************/
BOOL Validate_User(short int nSequenceNbr)
  {
  short int nStrCntr;
  char cTempString1[81], cTempString2[81];

  /************************************************/
  /*** Initialize the User/Password Descriptors ***/
  /************************************************/
  strcpy(cLogin_Name, sClientRcd[nSequenceNbr].cLogin);
  cLogin_Name_Desc.dsc$w_length  = strlen(cLogin_Name);
  cLogin_Name_Desc.dsc$a_pointer = cLogin_Name;

  DecryptString(sClientRcd[nSequenceNbr].cPassword, cPassword);
  cPassword_Desc.dsc$w_length  = strlen(cPassword);
  cPassword_Desc.dsc$a_pointer = cPassword;


  /**************************************************************/
  /*** RETURNS A QUADWORD VALUE OF THE USER'S HASHED PASSWORD ***/
  /**************************************************************/
  sGetUAI_List.sItem_Desc_Rcd.nBuf_Length         = 8;
  sGetUAI_List.sItem_Desc_Rcd.nItem_Code          = UAI$_PWD;
  sGetUAI_List.sItem_Desc_Rcd.cBuf_Addr           = &nPassWord;
  sGetUAI_List.sItem_Desc_Rcd.nReturn_Length_Addr = &nReturn_Length;
  sGetUAI_List.nTerminator                        = 0;

  nStatus = sys$getuai(0, 0, &cLogin_Name_Desc, &sGetUAI_List, 0, 0, 0);

  if(nStatus != SS$_NORMAL)
    {
    sprintf(cPut_Buffer,
        "[ERROR - %s]: CALLING SYS$GETUAI/UAI$_PWD %%",
            return(FALSE);
    }

  /************************************************************/
  /*** GET THE ENCRYPTION ALGORITHM USED FOR THE PASSWORD  ***/
  /***********************************************************/
  sGetUAI_List.sItem_Desc_Rcd.nBuf_Length         = 1;
  sGetUAI_List.sItem_Desc_Rcd.nItem_Code          = UAI$_ENCRYPT;
  sGetUAI_List.sItem_Desc_Rcd.cBuf_Addr           = &nPasswordEncrypt;
  sGetUAI_List.sItem_Desc_Rcd.nReturn_Length_Addr = &nReturn_Length;
  sGetUAI_List.nTerminator                        = 0;

  nStatus = sys$getuai(0, 0, &cLogin_Name_Desc, &sGetUAI_List, 0, 0, 0);

  if(nStatus != SS$_NORMAL)
    {
    return(FALSE);
    }

  /*****************************************************************/
  /*** GET THE PASSWORD SALT,  THIS IS USED TO HASH THE PASSWORD ***/
  /*****************************************************************/
  sGetUAI_List.sItem_Desc_Rcd.nBuf_Length         = 2;
  sGetUAI_List.sItem_Desc_Rcd.nItem_Code          = UAI$_SALT;
  sGetUAI_List.sItem_Desc_Rcd.cBuf_Addr           = &nPasswordSalt;
  sGetUAI_List.sItem_Desc_Rcd.nReturn_Length_Addr = &nReturn_Length;
  sGetUAI_List.nTerminator                        = 0;

  nStatus = sys$getuai(0, 0, &cLogin_Name_Desc, &sGetUAI_List, 0, 0, 0);

  if(nStatus != SS$_NORMAL)
    {
    return(FALSE);
    }

  /*************************************************************************/
  /*** USE THE SYSTEM SERVICE SYS$HASH_PASSWORD TO HASH THE INPUT PASSWORD */
  /*** THIS WILL THEN RETURN THE PASSWORD ENCRYPTED                      ***/
  /*************************************************************************/
  nStatus = sys$hash_password(&cPassword_Desc, nPasswordEncrypt,
                            nPasswordSalt, &cLogin_Name_Desc, &nReturn_Number);

  if(nStatus != SS$_NORMAL)
    {
    return(FALSE);
    }

  /**********************************************************************/
  /*** IF THE UAI PASSWORD (nPassWord) DOES NOT = THE INPUTTED HASHED   */
  /*** PASSWORD THEN THE PASSWORD IS INCORRECT                        ***/
  if(nPassWord != nReturn_Number)
    {
    return(FALSE);
    }

/***************************************************************************/
  


