This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Security and the fly likes How to read client m/c windows login id through JavaScript. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "How to read client m/c windows login id through JavaScript." Watch "How to read client m/c windows login id through JavaScript." New topic
Author

How to read client m/c windows login id through JavaScript.

Ramesh Biradar
Greenhorn

Joined: May 25, 2006
Posts: 2
Hi All,

Can any one tell me how to read the client machine windows login id.

Here my requirnment is whenever client request for page, I have to read client's windows login id and I have to compare againest the database(server). If id exists then I should allow user to access the application. If id does not exists, then I have to open login page for authentication.

Can anyone help me to know how to get the client m/c windows login id.

Thanks in advance

Regards,
Ramesh Biradar.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41133
    
  45
Welcome to JavaRanch.

I'm fairly certain that JavaScript does not have access to this kind of information, because that would be a breach of privacy. Can't the resource be protected by requiring standard server-side measures, like HTTP authentication or NT Challenge/Response?


Ping & DNS - my free Android networking tools app
AilBala Subramanian
Greenhorn

Joined: Jul 20, 2012
Posts: 1
dear friends,

I am new to asp.net with C#.
My requirement is getting system login user id while page loading and displaying user detail based on fetched userid.
I have used the following methods in code behind part:

1. Request.UserHostName;
2. Request.ServerVariables["AUTH_USER"] ;
3. Request.ServerVariables["LOGON_USER"] ;
4. System.Web.HttpContext.Current.User.Identity.Name;
5. Environment.GetEnvironmentVariable("USERNAME").ToString();
6. User.Identity.Name
7. this.Request.LogonUserIdentity.Name;
8. System.Security.Principal.WindowsIdentity.GetCurrent().Name;
9. System.Environment.ExpandEnvironmentVariables("%username%");
10. dynamic wshell = Server.CreateObject("WScript.Shell");
string test = wshell.ExpandEnvironmentStrings("%username%");

Everything giving expected output. But after deploying that file in server and executing the deployed file it is giving blank outputs and server names. but not my expected output (user id).
I am suffering with this problem for the past 3 days. any idea... please...

since code behind part is not giving my expected output. I have used the below clientscript method in javascript:
function get_user_id() {
var wshShell = new ActiveXObject("WScript.Shell");
document.getElementById('hiddenfield').value = wshShell.ExpandEnvironmentStrings("%USERNAME%");
alert(document.getElementById('hiddenfield').value);
}
called this function in onload event of the body tag. I am getting user id in popup alert box.
string X = hiddenfield.value; // <-- looking empty
but in my code behind part it is still empty. while seeing it in debug mode my page load event in code behind part is executing first then only scripts are executing.

So, via this method also I can't achieve my target. I am so confused what to do. Please help me.... :-(
 
Don't get me started about those stupid light bulbs.
 
subject: How to read client m/c windows login id through JavaScript.
 
Similar Threads
Java application crashes due to some problem in native code
Validate
Running Client Application from Windows98
event log capturing
Fetching windows login user id in struts