Forums Register Login
Problems with getRemoteUser()
I am trying to get the windows userid from the user when the go to my jsp. I have tried getRemoteUser but I keep getting null. Any sugestions/ideas? Here is my jsp code:

<%@ page import="java.util.*,java.sql.*, java.io.*, java.text.*, javax.servlet.http.*, javax.servlet" %>

String userid=request.getRemoteUser();
How are you authenticating users?
I have written a servlet:

import java.io.*;
import java.security.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Snoop extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();

out.println("User Name: " + req.getRemoteUser());
String name = (req.getUserPrincipal() == null) ?
null : req.getUserPrincipal().getName();
out.println("Principal Name: " + name);
out.println("Authentication Type: " + req.getAuthType());

Am I missing something here?
Can anyone look at my servlet and tell me what I a might be missing? I continue to get "null" for my output.
If you aren't going to answer Ben's question, how can anyone help you?
I am not sure what you mean...I am trying to get the windows userid, since it is an intranet the windows userid would already be authenticated, do I have to do this a second time in my servlet?
The point is that getRemoteUser will return the userid of the browser-authenticated user. It has nothing to do with the Windows (or any other OS) login.
Okay, so if someone is logged into the company intranet and they click on my jsp they have to be authenticated again?
Yes, if you want to use getRemoteUser()

Take a look at the documentation for JNDI resources:

I know it's also possible (but I've never done it) via JNDI to use windows authentication with Tomcat.
Google would be more help than I would for that.
Thanks, I will give it a whirl!
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

All times above are in ranch (not your local) time.
The current ranch time is
Oct 17, 2017 20:23:43.