• Post Reply Bookmark Topic Watch Topic
  • New Topic

request.getRemoteUser()

 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been using request.getRemoteUser() to find out the login name and domain name. But it used a filter NtlmHttp Flter for filtering. Can we use the same request.getRemoteUser() using Custom Servlet so we do not need to define the Filter.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35719
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nabajyoti,
Yes. The servlet has the request too and can get that information. The filter was used for filtering. If you need the remote user for some other purpose, a servlet is fine.
 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getHeader("Authorization");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "NTLM");
to obtain information and used a method sun.misc.BASE64Decoder().decodeBuffer()
The code worked fine for most of the browsers for mac safari it went into a loop and was giving null. Also we had implemented the code using a custom filter class.
When the code crashed for safari, i tried to change the code and implemented request.getRemoteUser() using NtlmHttpFilter and it worked fine for safari. But we had another requirement to make it domain compatible. When accessed from a different domain the code requst.getRemoteUser() does not seem to work as inside the ntlmHttpFilter one needs to mention the ip of the domain controller. now, iw as thinking if we cold write the same code in the custom java class filter which we initially built. now for doing that, dependind on the browser type i will choose the code.
However the code request.getRemoteUser() does not seem to work as it is showing null in the result.

can you please find out a way out?


Thanks for the reply.....
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35719
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nabajyoti,
It sounds like there are a couple problems in there. Let's start with the original one. Are you saying that printing the remote user worked in the filter, but not the servlet for the exact same request?
 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a custom filter in web.xml ...where i have metioned the name of the java class which will be doing the filtering part.

now when i use request.getRemoteUser()
it gives null.

what is the propwer code for obtaining request.getRemoteUser()?
Do I need to import any package for performing the operation?


can you please send me the code for doing the same?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35719
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still confused. Are you saying sometimes it works in the filter and sometimes it doesn't? Can you summarize the problem in one post.

It's not code you need - it's likely configuration. The code is just request.getRemoteUser().
 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

initialy i am using a custom filter.

the code is

now, this gives the login name and domain name for all browsers except mac.

So i thought of adding a code which will specifically execute in case it is called from any browser(safari or IE) in a mac.

so i thought of using request.getRemoteUser() but to my misery it was giving null.

when i tried it without custom filter and used a standard ntlmHttpFilter in the DD, it simply worked but as you know. In the filter you need to specify the domain controller.
Now, if the machines from different domains try to access the code, it will not work. However the above code with custom filter works fine for all domains.

So, in order to balance between the two, i though of adding request.getRemoteUser() to the above code which will be executed when the browser is safari or IE for mac.

So, i used String str = request.getHeader("user-agent");
//"Macintosh"
if(str.indexOf("Macintosh") > -1)

and chip in

request.getRemoteUser();


I hope this will present you the issue nicely....thanks

[edited to add code tags]
[ April 24, 2008: Message edited by: Jeanne Boyarsky ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35719
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, now I understand the question. I don't know the answer though. Hopefully someone else will see the elaborated question.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Well, now I understand the question.

Maybe you could explain it to me. I'm still at a loss.
 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The crux of the matter is:

I want to authenticate the users across browsers, across domains.

ie find out the name and domain name

What are the possible ways?
 
nabajyoti bhattacharjee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any luck on this.........
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!