File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP accessing Server Variables( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP accessing Server Variables("LOGON_User")" Watch "JSP accessing Server Variables("LOGON_User")" New topic
Author

JSP accessing Server Variables("LOGON_User")

Jon McLinn
Greenhorn

Joined: Oct 06, 2003
Posts: 2
I am trying to access the Server Variable("LOGON_USER") to authenticate a user. Does anyone have any coding examples? Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jon McLinn
Greenhorn

Joined: Oct 06, 2003
Posts: 2
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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 ]
Jeff Binnig
Greenhorn

Joined: Jul 02, 2001
Posts: 13
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.


Mostly Oracle, C#, VB, SQL Server, ASP.NET, COM+, JSP, Java, Servlets.
Jeff Binnig
Greenhorn

Joined: Jul 02, 2001
Posts: 13
request.getHeader("CGI Header variable")

is the method call to retrieve the variable information.
Jeff Binnig
Greenhorn

Joined: Jul 02, 2001
Posts: 13
<%@ 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>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP accessing Server Variables("LOGON_User")