CGI & Netscape Enterprise Server authentification

How can I pass the current login name used in an HT password window to a CGI?
(The web server is Netscape Enterprise 2.01)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sorry, what's HT?
If you mean the .htaccess method then the environmental variable
REMOTE_USER will give you the users login.
xmeAuthor Commented:
Ok, I tried REMOTE_USER and REMOTE_IDENT... Nothing!
Could you provide me an example?

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Are you talking about the User and Pass screen that a browser displays when you try to access a secured realm on your web server?

If so, let me know as I have done some work with this stuff just recently.

xmeAuthor Commented:
Using Netscape Enterprise server, when you set the 'Restrict Access' mode with a user database, you receive a prompt window when you access a protected zone of the site.
This is the login passed via this window that I want to use in
in C, it would be:
char *userid;
userid = malloc(strlen(getenv("REMOTE_USER")) + 1);
strcpy(userid, getenv("REMOTE_USER");

in perl:

$userid = $ENV{'REMOTE_USER'};


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sorry, malloc() and getenv() may return NULL.
A safe code should look something like this:

char *temp;
char *userid;

if(temp = getenv("REMOTE_USER")) { /* env var found */
  if(!(userid = malloc(strlen(temp) + 1))) return MALLOC_FAILED;
  strcpy(userid, temp);
else {  /* env var not found */
  if(!(userid = malloc(1))) return MALLOC_FAILED;
  *userid = '\0';

Rgds, julio
oh yeah, big deal.

What's wrong with

char *user_id;

user_id = getenv("REMOTE_USER");

Why allocate memory, and duplicate the value, while it's already available? Unless you need to change it..
 Hello mgjv,

you are right, unless you need to change that value, _and_ unless you are going to get more than just one env variable.

Each call to getenv() overwrites the previous value, since the pointer returned by getenv() is a pointer to a static variable.

That is, say you have something like this:

char *rm, *qs, *ru;

rm = getenv("REQUEST_METHOD");
qs = getenv("QUERY_STRING");
ru = getenv("REMOTE_USER");

This code would end up with the same value for rm, qs and ru, which is the location of the unique static variable handled by getenv(), and that static variable would point to the value requested in the last call to getenv(), i.e. "REMOTE_USER".

HTH, despite of my English :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.