Solved

Using Javascript and .htaccess

Posted on 1997-08-12
4
294 Views
Last Modified: 2008-03-10
Is there a way using JavaScript to get the username of someone who logs into a page protected by a htaccess file?  I would just use CGI for this (the REMOTE_USER environment variable), but for some strange reason my server isn't configured to use htaccess under the cgi-bin directory.
0
Comment
Question by:jgottden
[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
4 Comments
 

Expert Comment

by:srudy
ID: 1268938
The only way to get this information, due to javascript's limited security is to call an external program.  I would say you should try to figure out why you can't access the REMOTE_USER variable and go from there.

If you are using Netscape Enterprise server and LiveWire there is a way to call an external C library and access the REMOTE_USER variable as well.  I have the code for that method.  However it sounds like you know how you are going to get the information from using CGI scripting, so you should proably just stick to that solution.

Good luck...

Scott Rudy
0
 
LVL 1

Expert Comment

by:909233
ID: 1268939
In Javascript you may not necessarily get the username but you
most certainly can obtain the user's browser/ip address
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1268940
i don't know why you rejected srudys' answer - it was obviously correct!
0
 
LVL 1

Accepted Solution

by:
gabsi earned 50 total points
ID: 1268941
U have to use a protected CGI ie: a CGI which needs authentification to be accessed.
Than the REMOTE_USER variable can be used.
Note that REMOTE_USER variable does not mean the useridentification on his own machine. Only AS WHO is he known for your CGI.The value of this variable is file/directory dependant:
A same user may have 2 differents REMOTE_USER values for 2 cgi which have different access rules.
I dont see how does your server refuse to protect some directories you want to (cgi or others).
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 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