Get user id in CGI RPG program

115 pts.
Tags:
CGI
Java
RPG
RPGLE
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Lenny2113
    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
    115 pointsBadges:
    report
  • Littlepd
    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.
    1,130 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following