views:

94

answers:

3

I have run into a brick wall with a Windows Service I wrote. The Windows Service is a proxy server for Internet Explorer. I am using the C# proxy from Mentalis (http://www.mentalis.org/soft/projects/proxy/) with some minor tweaks to make it run as a service.

IE can connect to my proxy and get the webpage it wants without any problems but I would like to know which Windows user is hitting the proxy. WindowsIdentity.GetCurrent().Name returns the account that the service is running under (NT AUTHORITY\SYSTEM).

How can I determine the user making the request? Is this possible?

+2  A: 

I don't think you can. The proxy server is just a TCP server; there's nothing about identity that's being transmitted as part of those requests.

Joe
+3  A: 

You have to implement authentication with your proxy server in order to determine the user. Otherwise the short answer is no, it is not possible.

Igor Korkhov
Exactly. Your browser only sends authentication information if the server asks for it and most don't
Chris Haas
I am very new to network programming. The Mentalis proxy is using Sockets to make and handle the requests. Could give me an idea where to start to ask the browser for authentication?If IE is only passing on the request to the Ip and port in the proxy settings how does it know if authntication is required by my code?
modernzombie
@modernzombie: A browser will know that it needs to authenticate itself to a proxy when it recieves "407 Proxy Authentication Required" status code from the proxy.But since there's a poll on Mentalis website titled "What would you like to see added to the proxy server?" and one of the answers is "authentication features" I assume that Mentalis proxy doesn't support authentication.
Igor Korkhov
Is it possible for my proxy to always tell the browser it needs to authenticate and then intercept the information?
modernzombie
@modernzombie: Yes, sure it is possible. But in your case you need to add authentication logic on your own, since Mentalis doesn't support it out of the box.
Igor Korkhov
A: 

HttpContext.Current.Request.ServerVariables["LOGON_USER"] would be the only reliable way, and that would only work if it was on a local network implementing Windows Auth.

Joel Etherton