Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

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

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Ramesh Biradar.
Posts: 43011
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear friends,

I am new to 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%");
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.... :-(
Let nothing stop you! Not even this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!