I have a small in-house application and I need to know which domain user is accessing the site, without requiring site authentication- I just need to know who they are logged onto their machine as, and capture that info. This is just for logging, not for any kind of access control. Within the company this is just an open site.
Is there a simple way from a Web.API app controller to find out who is the current domain user on the machine? Do I need to configure something in my web.config?
This is not possible, or at least not possible reliably.
First, the only way to get the user is actually use windows authentication and force them to log in. You can use Windows pass-through authentication, but that only works with Internet Explorer, and it only works in very specific domain configurations. Even then, sometimes it doesn’t work. When it doesn’t work (if they’re using chrome or ff or just don’t have the browser configured correctly) it will force them to login with their credentials. This is the only way.
This could also be done with an ActiveX control, but again that only works in IE, and most corporate environments are not keen about activex anymore. It could work with Java (not javascript) but given the recent security issues with Java, maybe not a good idea either.
In any event, there is no real foolproof way to do this. Only a bunch of different kinda-sorta ways that may or may not work.