Solved

Access network credentials using javascript

Posted on 2012-04-12
13
803 Views
Last Modified: 2013-11-21
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
Comment
Question by:EntAppDevTeam
  • 5
  • 4
13 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37841064
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37841301
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37841313
You will need to "save/open" it from the web or copy it to your intranet users if that is what you need.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 250 total points
ID: 37841321
hmm, let's see if the author ask for an intranet solution which requires IE policies set to ignore any security ...
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 37841326
If not, then the answer is: not possible
0
 

Author Comment

by:EntAppDevTeam
ID: 37843327
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37843387
question answered, isn't it?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37843846
hmm, mplungjan helped answering too, IMHO ...
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37844158
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37844508
@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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery Validation Messages Not Showing Up 3 20
Html form and modal / img src -problem 3 28
Google Analytics setup 5 50
Html value of radio 14 27
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question