Solved

CGI & Netscape Enterprise Server authentification

Posted on 1997-08-14
10
224 Views
Last Modified: 2013-12-25
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)
0
Comment
Question by:xme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1829679
Sorry, what's HT?
-julio
0
 
LVL 5

Expert Comment

by:icd
ID: 1829680
If you mean the .htaccess method then the environmental variable
REMOTE_USER will give you the users login.
0
 

Author Comment

by:xme
ID: 1829681
Ok, I tried REMOTE_USER and REMOTE_IDENT... Nothing!
Could you provide me an example?

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Expert Comment

by:mravell
ID: 1829682
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.


Regards
Marty
0
 

Author Comment

by:xme
ID: 1829683
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
CGIs...
0
 

Accepted Solution

by:
ernst earned 100 total points
ID: 1829684
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'};

0
 
LVL 5

Expert Comment

by:julio011597
ID: 1829685
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
0
 

Expert Comment

by:ernst
ID: 1829686
oh yeah, big deal.
0
 

Expert Comment

by:mgjv
ID: 1829687
Errmmm...

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..
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1829688
 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 :)

-julio
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question