Article 137583 of comp.os.vms:
Path: nntpd.lkg.dec.com!lead.zk3.dec.com!crl.dec.com!crl.dec.com!bloom-beacon.mit.edu!newsfeed.internetmci.com!howland.reston.ans.net!usc!news.cerf.net!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
Newsgroups: comp.os.vms
Subject: Re: password routine?
Date: 11 Jan 1996 22:10:23 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 60
Distribution: world
Message-ID: <4d41sf$44e@gap.cco.caltech.edu>
References: <1996Jan11.090248@cctr.umkc.edu>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
NNTP-Posting-Host: sol1.gps.caltech.edu

In article <1996Jan11.090248@cctr.umkc.edu>, dhayden@cctr.umkc.edu writes:
=Without privs is there any way to write a routine on VMS which will prompt the
=user for their password to continue.
=
=Like:
=
=Enter Password:
=(using their account password)

#include descrip
#include UAIDEF
#include jpidef
#define ckstat(x) if(((stat = x) & 7) != 1) return stat

main(int nargs, char **args)
{	unsigned long SYS$HASH_PASSWORD(), SYS$SETUAI(), SYS$GETUAI(),
		SYS$EXIT(), STR$UPCASE(), SYS$GETJPIW(), puts(), strlen();
	$DESCRIPTOR(pwd, "");
	static unsigned char alg, username[32];
	$DESCRIPTOR(usrnam, username);
	static unsigned short salt, username_length, iosb[4];
	static unsigned long hash[2], password[2], stat;
	struct ITEM_LIST_3
	{	unsigned short buflen, itmcod;
		unsigned long bufadr, reslen;
	} itmlst1[] =
	{	{ 1, UAI$_ENCRYPT, (unsigned long) &alg, 0 },
		{ 2, UAI$_SALT, (unsigned long) &salt, 0 },
		{ 8, UAI$_PWD, (unsigned long) password, 0 },
		{ 0, 0, 0, 0 }
	}, itmlst2[] =
	{	{ 32, JPI$_USERNAME, (unsigned long) username, (unsigned long)
			&usrnam.dsc$w_length },
		{ 0, 0, 0, 0 }
	};

	if (nargs != 2)
	{	puts("Usage: CHECK_MY_PASSWORD password");
		SYS$EXIT(1);
	}
	ckstat(SYS$GETJPIW(0, 0, 0, itmlst2, iosb, 0, 0));
	ckstat(iosb[0]);
	pwd.dsc$a_pointer = *++args;
	pwd.dsc$w_length = strlen(*args);
	ckstat(STR$UPCASE(&pwd, &pwd));	
	ckstat(SYS$GETUAI(0, 0, &usrnam, itmlst1, 0, 0, 0));
	ckstat(SYS$HASH_PASSWORD(&pwd, alg, salt, &usrnam, hash));
	if((hash[0] != password[0]) || (hash[1] != password[1]))
		puts("Invalid username/password pair");
	else
		puts("Valid username/password pair");
}
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.


