ALTER IN PROC *C

From: Mark Allen <mallen_at_ncrcetc.WichitaKS.NCR.COM>
Date: 31 Aug 93 15:23:52 GMT
Message-ID: <568_at_ncrcetc.WichitaKS.NCR.COM>


I am trying to write a PRO *C program that changes a users password. They code sample I have included logs on to ORACLE fine, but gives me a 01935 error on the alter stmt. I would like all users to execute this program but currently only those with DBA priv's are allowed to run this. Does anyone have any ideas or suggestions? Surely someone has done this before. Please email me directly as my newsfeed is not all that reliable.

Thanks in advance.

Mark Allen	Mark.Allen_at_WichitaKS.NCR.COM
NCR CETC	mallen!ncrcetc!ncrwic!ncrcom!{uunet...}

#include <stdio.h>
#include <string.h>

EXEC SQL BEGIN DECLARE SECTION;
        VARCHAR uid[20], pwd[20], newpwd[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA.H; main(argc,argv)
int argc;
char *argv[];
{

	if (argc != 4 ){
		printf("Usage: passer <userid> <current password> <new password>\n");
		exit(-1);
	}
	else{
		strcpy(uid.arr,argv[1]);
		strcpy(pwd.arr,argv[2]);
		strcpy(newpwd.arr,argv[3]);
		
		if((outfile = fopen(RSLTFILE,"a")) == NULL) {
			printf("Do not have permission to open %s\n",RSLTFILE);
			exit(-2);

}
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd; if(sqlca.sqlcode == 0 ) printf("Connected to Oracle user: %s \n",uid.arr); else{ printf("Could not logon\n"); exit(-3);
}
EXEC SQL alter :uid identified by :newpwd; if(sqlca.sqlcode == 0) printf("password changed\n"); else{ printf("Could not alter password for %s with password %s and new password %s\n",uid.arr,pwd.arr,newpwd.arr); exit(-4);
}
}

}
-- 
  Mark Allen       Internet: mallen!ncrcetc!ncrwic!ncrcom!{uunet..}
   NCR CETC        NCR WIN: Mark.Allen_at_Wichita.NCR.COM
An AT&T Company    VP 530-4726  PHONE (316)636-4726
                "NCR CETC, ISO REGISTRATION COMING SOON!"
Received on Tue Aug 31 1993 - 17:23:52 CEST

Original text of this message