• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP accessing Server Variables("LOGON_User")

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access the Server Variable("LOGON_USER") to authenticate a user. Does anyone have any coding examples? Thanks
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Luven, welcome to the Ranch!
If the LOGON_USER element you are referring to is an environment variable, then there is no supported way in Java (and this is in general, not just in the JSP arena) to obtain its value.
What is generally done is to take the value of 'interesting' environment variables and declare them as Java system properties which you can then access through Java APIs.
But I'm not even sure that this is what you really want to do since generally the servlet container is run as root. What user value are you really trying to obtain? The user logged on that is using the browser? The user that started the server? Other?
bear
 
Jon McLinn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well what I am trying to do is we have an intranet application written in JSP and I want to athenticate the user, without a login prompting for credentials. So I need to access the the userid from the our network. Does this help, is there anything I can do to access this information?
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, there is no standard Java way to accomplish this (not surprising since it is platform-specific).
If you will give details as to the nature of your intranet (what OS, what servlet container, and so on), perhaps someone has worked out a hack to do this for your configuration.
IMHO, your best bet is for your intranet to perform its own authentication -- either home-grown or container-managed.
bear
[ October 06, 2003: Message edited by: Bear Bibeault ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have an SSO(Single Sign On) solution like Siteminder or RSA, you can log in to a web app without a login prompt.

Or, you can use the Windows Integrated Login emulation in Apache, or use IIS and have the client change their IE settings to log them in automatically.

I geeked a bit with latter, but we are going into production with the former.

I prefer the former, rather than the latter.
 
Jeff Binnig
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.getHeader("CGI Header variable")

is the method call to retrieve the variable information.
 
Jeff Binnig
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ page language="java" import="com.bo.wibean.*, java.util.*, com.bo.infoview.*" errorPage="/scripts/tools/err_page.jsp"%>
<html>
<head>
</head>
<title>JSP Server variables</title>
<body>
<table border=1 cellspacing=0 cellpadding=2>
<%
String strHeaderName = "";
for(Enumeration e = request.getHeaderNames(); e.hasMoreElements()
{
strHeaderName = (String)e.nextElement();
%>
<tr>
<td><%= strHeaderName %></td>
<td><%= request.getHeader(strHeaderName)%> </td>
</tr>
<%
}
%>
</table>

</body>
</html>
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A web server isn't the same thing as a LAN server. What you're almost certainly trying to do is extract the username by which the intranet user logged into a Windows Domain. That information isn't part of the Internet HTTP protocols, since I could be connected to multiple HTTP servers all over the world, some of which might be located on machines on Windows domains that were totally unrelated (and might even have my domain user id assigned to some other person entirely).

That would be a SSO solution and it's generally messy and/or expensive. You need some sort of authentication server that makes common cause between Windows Networking and HTTP. Also, each intranet user that uses such authentication for HTTP requires that their copy of Internet Explorer be set to permit it. Yes, I know it's hard to believe, but there is a security feature that Microsoft left turned OFF by default.
 
reply
    Bookmark Topic Watch Topic
  • New Topic