• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

Access network credentials using javascript

Is there anyway to access network credentials with javascript without having to manually set them? This is needed in order to pass the credentials dynamically to a webservice. The webservice is setup for windows authentication and the browser is IE8.
0
EntAppDevTeam
Asked:
EntAppDevTeam
  • 5
  • 4
2 Solutions
 
Michel PlungjanIT ExpertCommented:
Try the code mentioned here.
http://www.ureader.com/msg/16721933.aspx
<script language=javascript>   
  function getNTUsername(){
  
var wshNetwork = new ActiveXObject("WScript.Network");   
        alert('domain ='+   wshNetwork.UserDomain);   
        alert('machine name = '+   wshNetwork.ComputerName);   
        alert('user name = '+   wshNetwork.UserName);
        document.getElementById('username').value = wshNetwork.UserName;
        document.getElementById('UsernameDiv').innerHTML = 
wshNetwork.UserName;
  }
</script>   

Open in new window


However your HTML has to be saved with extension .hta and has to be loaded from hard disk
0
 
ahoffmannCommented:
mplungjan, just for curiosity: how would a local stored .hta file be loaded/used by a page send from anywhere without violating the SOP?
(sorry for the silly question, as I'm no IE and M$ guru ;-)
0
 
Michel PlungjanIT ExpertCommented:
You will need to "save/open" it from the web or copy it to your intranet users if that is what you need.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
ahoffmannCommented:
hmm, let's see if the author ask for an intranet solution which requires IE policies set to ignore any security ...
0
 
Michel PlungjanIT ExpertCommented:
If not, then the answer is: not possible
0
 
EntAppDevTeamAuthor Commented:
This won't work.  At best, the user will be prompted to allow on every page load. Check it out http://forums.asp.net/t/1124769.aspx
0
 
ahoffmannCommented:
question answered, isn't it?
0
 
ahoffmannCommented:
hmm, mplungjan helped answering too, IMHO ...
0
 
Michel PlungjanIT ExpertCommented:
I believe I did.

What you are trying to do is a security risk, hence it only works on the lowest security level - that is when the user started the HTA him/herself

this cannot be done from a web page from a web server
0
 
ahoffmannCommented:
@all: I fully agree with mplungjan's comments and helped to point out the limits
sorry for beining a bit short in my comments, but mplungjan got them all:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now