Reputation: 19944
I am developing an asp.net
project that will be running in a lan.
Every user in this lan has its own system username.
This application will be running only on internet explorer browser.
I want to identify every client with its username.
Is there any way to do this using javascript?
Upvotes: 0
Views: 6225
Reputation: 34909
In theory this should work for Internet Explorer, but could fail if the security settings on the browser are locked down.
var wshshell=new ActiveXObject("wscript.shell");
var username=wshshell.ExpandEnvironmentStrings("%username%");
alert('hello, ' + username);
Also, it isn't guaranteed to 100% of the time match their actual AD login name.
If you are using ASP.NET you can do this much more reliably in a server-side script using Request.ServerVariables("AUTH_USER")
or another technique if you are using forms based authentication.
Upvotes: 1