Use a debugger, set a breakpoint in your code and examine the
principle that represents the user. IIRC, the request has a reference
to the user principle.


On Thu, 3 Feb 2005 08:54:20 -0800 (PST), Denny Lee <[EMAIL PROTECTED]> wrote:
> Hello,
> Thanks for your reply.  When I use IE to bring up the
> page I get a dialogbox asking for user name and
> password.  If I put in a user name and password of a
> user on the workstation I can login.  The page shows
> the correct user name and says that I have
> successfully logged in.  But I get 2 false for the
> isUserInRole statements.  I don't know why that is the
> case.
> 
> Thanks.
> 
> >---------------------------------------------------------------------
> Hi!
> 
> I'm not sure, but I think your code is OK. The
> question is: How did you
> configure your security realm in web.xml and
> server.xml.
> (request.isUserInRole only works, if the user has
> already been
> authenticated against the web server.)
> 
> Best regards,
>   Tex
> 
> >Hello,
> >I am trying to use isUserInRole in an app within
> >Tomcat.  The problem is that I consistently get false
> >as the return regardless of what I pass in.  I am
> >using J2SE 1.4.2_06 and Tomcat 5.0.  Here is the code
> >and any help would be great:
> >
> >import java.io.*;
> >import javax.servlet.*;
> >import javax.servlet.http.*;
> >
> >public class NtlmHttpAuthExample extends HttpServlet
> {
> >
> >    public void doGet( HttpServletRequest req,
> >                HttpServletResponse resp ) throws
> >IOException, ServletException {
> >        PrintWriter out = resp.getWriter();
> >
> >        resp.setContentType( "text/html" );
> >        out.println( "<HTML><HEAD><TITLE>NTLM HTTP
> >Authentication Example</TITLE></HEAD><BODY>" );
> >        out.println( "<h2>NTLM HTTP Authentication
> >Example</h2>" );
> >
> >        out.println( req.getRemoteUser() + "
> >successfully logged in" );
> >
> >
> >       out.println(req.isUserInRole("admin"));
> >
> >
> >       out.println("<br>-");
> >       out.println(req.isUserInRole("Administrators"));
> >
> >        out.println( "<h3>Please submit some form
> data
> >using POST</h3>" );
> >        out.println( "<form
> >action=\"NtlmHttpAuthExample\" method=\"post\">" );
> >        out.println( "<input type=\"text\"
> >name=\"field1\" size=\"20\"/>" );
> >        out.println( "<input type=\"submit\"/>" );
> >        out.println( "</form>" );
> >
> >        out.println( "field1 = " + req.getParameter(
> >"field1" ));
> >
> >        out.println( "</BODY></HTML>" );
> >    }
> >    public void doPost( HttpServletRequest req,
> >                HttpServletResponse resp ) throws
> >IOException, ServletException {
> >        doGet( req, resp );
> >    }
> >}
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to