Get user id in CGI RPG program
115 pts.
0
Q:
Get user id in CGI RPG program
Please, kindly advise on this issue I am having. Program is coded in RPG and is a CGI module. I tried to get user-id from program data structure, but this "UserID 254 263", but it shows QTMHHTTP, because this pgr runs on HTTP server. How else can I obtain real user-id of the user who is envoking the program. Thank you
ASKED: Aug 12 2009  6:31 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
500 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
I haven't done CGI but I've created Stored Procedures to be called from the web, so I don't know if this is relevant but in that situation we had to pass the user id to the web pages (hidden field) and have the web page hand it back.

Phil


/////

Hi,

First of all, it's important to know how you configured your HTTP server. Have you used UserID directive? Does your programs change User Profile explicitly?

You can try taking user ID from positions 358-367 (Current User ID) of PSDS.

Regards,
Wilson

/////////

How are you protecting your site folders? Validation List?

When a user is required to log in to get to your secure web site, environment variables are created and made available to both the client (for any scripts that may run in the browser) and the server (for server-side scripts, or CGI). One of those environment variables is the user ID that was used to log in.

IBM provides an API to access the environment variables for the session that is running. The Get Environment Variable (QtmhGetEnv) API allows you to get the value set by the server for a particular HTTP environment variable. The name of the environment variable you want in this case is REMOTE_USER.

If you are using the CGIDEV2 toolset, you may retrieve the value set by the server for a particular HTTP environment variable by using the subprocedure GetEnv. This procedure calls QtmhGetEnv API.

Michael
Last Answered: Aug 13 2009  3:59 PM GMT by Littlepd   500 pts.
Latest Contributors: WilsonAlano   2005 pts., Philpl1jb   24530 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Lenny2113   115 pts.  |   Aug 13 2009  7:33PM GMT

Michael, I appeciate your feedback on this one.
Please let me know what I am doing wrong here.
My field that expects userid input is called UserName.
We want to make it default to the current user instead of allowing users to type whatever they want..

I have included this code as part of my CGI program under process ( C $ProcInput Begsr )
C Eval EnVarName = ‘REMOTE_USER’
C Eval EnVarLen = %Len(%Trim(EnVarName))
C CallP APIEnVar(InBuffer:InBufLen:InActLen:
C EnVarName:EnVarLen:apiError)

Can I now set my UserName field to EnVarName ?

I tried this code :
D UserID 358 367
and assigned UserID to UserName, but instead of real user id I displayed the name of server instance QTMHHTTP1
These are my jobs related to the process…. (Current User = “QTMHHTTP”)

Current
Subsystem/Job User Type CPU % Function Status
QHTTPSVR QSYS SBS .0 DEQW
ADMIN QTMHHTTP BCH .0 PGM-QZHBMAIN SIGW
ADMIN QTMHHTTP BCI .0 PGM-QZSRLOG SIGW
ADMIN QTMHHTTP BCH .0 PGM-QLWISVR JVAW
ADMIN QTMHHTTP BCI .0 PGM-QZSRHTTP SIGW
ADMIN LENNY BCI .0 PGM-QZSRCGI TIMW
ADMIN2 QLWISVR BCI .0 JVM-com.ibm.lw THDW
IBMTEST QTMHHTTP BCH .0 PGM-QZHBMAIN SIGW
IBMTEST QTMHHTTP BCI .0 PGM-QZSRLOG SIGW
IBMTEST QTMHHTTP BCI .0 PGM-QZSRLOG SIGW
IBMTEST QTMHHTTP BCI .0 PGM-QZSRHTTP SIGW
IBMTEST QTMHHTTP BCI .0 PGM-QZSRHTTP DEQW
IBMTEST QTMHHTP1 BCI .0 PGM-QZSRCGI TIMW

 

Littlepd   500 pts.  |   Aug 14 2009  3:51AM GMT

Has the user already logged in at this point?

After you call the API, the user id of the current session user can be found in the InBuffer variable.

 
0