• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

Regards,
Ramesh Biradar.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.... :-(
 
Slime does not pay. Always keep your tiny ad dry.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic