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.
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.
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?
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
I hope this will present you the issue nicely....thanks
[edited to add code tags] [ April 24, 2008: Message edited by: Jeanne Boyarsky ]