2

I'm trying to get the windows user name of the user in my web application. Can any one suggest how to get it?

I'm developing a web application. So if a user is accessing my application, then I need to get the user's windows id and his host name. I tried a few different ways but it never worked. Any suggestions are highly appreciated.

Vadzim
  • 24,954
  • 11
  • 143
  • 151
Arun Kumar
  • 33
  • 2
  • 11
  • 1
    Is it a intranet web application or a public? In case it is intranet have a look at Kerberos and http://msdn.microsoft.com/en-us/library/aa745042(v=bts.10).aspx – Daniel Kutik Aug 16 '12 at 14:11
  • Do you mean from the server? In which case you can't. You have to rely on what your server has access to. And this isn't sent with the request. So you have to ask the user. If you mean from the client's browser, I'm pretty sure javascript won't work either because browsers consider it a security thing. – CrazyPenguin Aug 16 '12 at 14:24
  • Other than request or response or a request header, is there any other way? – Arun Kumar Aug 16 '12 at 15:42

4 Answers4

1

Windows user details are not sent in plain HTTP requests, which makes it impossible for you to derive them from a user in a web application without additional data. The host name from which the request is sent is available in the request headers, though.

If you'd still like to get Windows user details, you'll have to do some work, like ask the user to provide them in some form, or, if you have access to the user's Naming/Directory service, you can find things out through his IP/hostname. This is something you generally don't have readily available in web applications, though.

Kraylog
  • 7,383
  • 1
  • 24
  • 35
0

In YERY OLD(!) version of Internet Explorer the pattern %USER% inside of a URL was replaced by the login username. But with current browsers this doesn't work anymore, and that's good that way.

With JAVA applet you can request it via:

System.getProperty("user.name")

But I don't know if this works for you...

Vadzim
  • 24,954
  • 11
  • 143
  • 151
SDwarfs
  • 3,189
  • 5
  • 31
  • 53
0

Im not sure exactly to get the windows user name, but HTML5 The System Information API may provide some useful info. Go through this link once, You may find it helpful.

RP-
  • 5,827
  • 2
  • 27
  • 46
0

For the intranet case take a look at

How to retrieve the current windows logged on user for Single Sign On purposes in Java

and

Can you get a Windows (AD) username in PHP?

And it seems to be intentionally impossible in common case with modern browsers:

Can your Windows or Linux username be exposed to websites?

Community
  • 1
  • 1
Vadzim
  • 24,954
  • 11
  • 143
  • 151