Now Place:2uzhan.com » Retrieving the user id

Retrieving the user id

Scripting - Client Side @ June 2, 2004   Views:0

I would like to know how to retrieve the user id of a certain computer. This is a project in my company and I would like to get the user id of an employee to retrieved by jsp. The idea is that the employee does not have to login to a site in the intranet, rather he/she goes there and the id is automatically retrieved. Then the user id should be saved to a mysql database(that part isn't too much of a problem). If you have any tutorials or examples that would be very helpful. Thanks in advance.


Well I went to jGuru.com, that was a waste of time.

This is what I've been able to dig up...


String auth = request.getHeader("Authorization");

if (auth == null)
  response.setHeader("WWW-Authenticate", "NTLM");


if (auth.startsWith("NTLM "))
  byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
  int off = 0;
  int length;
  int offset;

  if (msg[8] == 1)
    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, z, z, z, z, z, z, z, z};
    response.setHeader("WWW-Authenticate", "NTLM " +
    new sun.misc.BASE64Encoder().encodeBuffer(msg1));

  else if (msg[8] == 3)
    off = 30;

    length = msg[off+17]*256 + msg[off+16];
    offset = msg[off+19]*256 + msg[off+18];
    String remoteHost = new String(msg, offset, length);

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

    length = msg[off+9]*256 + msg[off+8];
    offset = msg[off+11]*256 + msg[off+10];
    String username = new String(msg, offset, length);


I found this in one forum. I googled the "single sign-on" phrase.
Any advice on the above program or any of my previous questions would be helpful. I really hope that someone can help me out on this, I suck at JSP, so in some respects I'm a little bit desperat at the moment. Is the stuff that I found above correct or do you have any specific examples of your own that addresses this problem. Thank you.

Ok, it looks like I have the option of doing this in ASP. Does anyone know if it is possible to make ASP access data in a Linux server? Thanks in advance.

Can someone tell me if this is even possible at all? Has anyone heard of this being done at all? Any info will help right about now. Thanks.

I odn't know what the code you posted does - there were no comments on it.

Where do you expect to pick up the user id from if the user doesn't input it?

Remember that JSP doesn't run on the client PC, it runs on the server and just generates an HTML page that gets sent to the client. Your JSP could pick up a user id from a server-side database, but it would need some key from the client side. In principle, you could use the client IP address from the HTTP request, but in practice this may not be static, or it may resolve to a common proxy...

Today, most software exists, not to solve a problem, but to interface with other software...
I. O. Angell

The program that I did find was from another forum, not much there though .

I realize that java server pages and servlets run from a server, I was hoping that there would be some way to nudge the user pc and tell him to send his user id.

I was hoping that one might have a separate java class (not a jsp page) that handles such searching for a server page. That class could be put into a package, that package would be included in the jsp page and then used to send the user id whenever the server needs get the id of a newly arrived user. This java class-packaging thingy is my new project over the weekend officially.

Don't know. The only thing that I can do now is ask question and continue to research this topic on google. And try different stuff out as I go along. I can't seem to find a good example that will do exactly what I want or atleast hint at some idea.

© 2018 2uzhan.com Contact