Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2003, 02:26 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default NT Authentication

Hi.

I am trying to get the NT username of the client accessing my Websphere server. I have tried using request.getRemoteUser(), but it returns me "null".

Anyone of you knows how to do this???

Please help!

:D:)



YWT
__________________
YWT
 
Old June 11th, 2003, 04:28 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have found the solution...

But now .. I have another problem ... how do I grab the groups that this particular user is in



YWT
 
Old July 28th, 2003, 12:26 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you tell me how youo solved your first problem? I am having the same issue. Thanks.

 
Old July 28th, 2003, 07:38 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by hermlo
 Can you tell me how youo solved your first problem? I am having the same issue. Thanks.


Not sure if this would work for you. =)

Code:
<%@ page import="sun.misc.BASE64Encoder,java.util.*,java.lang.*,java.io.*,java.text.*,javax.naming.*,javax.naming.directory.*" %>
<%@ page language="java" contentType="text/html" %>

<%  
   String auth = request.getHeader("Authorization");
      if (auth == null) 
         {
            response.setStatus(response.SC_UNAUTHORIZED);
            response.setHeader("WWW-Authenticate", "NTLM");
            return;
         }
      if (auth.startsWith("NTLM ")) { byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5).trim());
         int off = 0, length, offset;
         String s;

            if (msg[8] == 1) { // first step of authentication
            off = 18;

         // this part is for full hand-shaking, just tested, didn't care about result passwords
         byte z = 0;
         byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S', (byte)'S', (byte)'P', z,
         (byte)2, z, z, z, z, z, z, z,
         (byte)40, z, z, z, (byte)1, (byte)130, z, z,
         z, (byte)2, (byte)2, (byte)2, z, z, z, z, // this line is 'nonce'
         z, z, z, z, z, z, z, z};

         // remove next lines if you want see the result of first step
         response.setStatus(response.SC_UNAUTHORIZED);
         response.setHeader("WWW-Authenticate", "NTLM " + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
         return;

         } 

      else if (msg[8] == 3) { // third step of authentization - takes long time, nod needed if zou care only for loginname
      off = 30;
      length = msg[off+17]*256 + msg[off+16];
      offset = msg[off+19]*256 + msg[off+18];
      s = new String(msg, offset, length);      
      } else
      return;

      length = msg[off+1]*256 + msg[off];
      offset = msg[off+3]*256 + msg[off+2];
      s = new String(msg, offset, length);

      length = msg[off+9]*256 + msg[off+8];
      offset = msg[off+11]*256 + msg[off+10];
      s = new String(msg, offset, length);
      out.println(s);
      }

%>
Good luck! :D

YWT
 
Old November 18th, 2004, 02:14 AM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Using Servlets and oc4j 9.0.2 in my web application.
I am trying to get user name and domain using the given sample code. I created a method called onAutoLogin and placed the given sample code in that.

To avoid giving user name, domain and password, I calling the method "onAutoLogin" directly. But this is not working.

I am always getting auth variable null. Even I did try to call the same method more than once. Still auth variable is null.

What exactly I am missing here?





Similar Threads
Thread Thread Starter Forum Replies Last Post
NT Authentication Possible? acdsky Classic ASP Basics 6 February 13th, 2008 07:36 PM
Connect to SQL Server using NT Authentication (ADO donnie200 Access VBA 5 July 15th, 2005 06:33 AM
NT Server 4.0 LiamUk BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 July 30th, 2004 05:32 AM
NT Authentication without Active Directory reyboy SQL Server 2000 0 October 15th, 2003 03:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.