Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Domain User Name 1

Status
Not open for further replies.

AlanDI1

Programmer
Apr 20, 2003
56
I am working on a browser based application. It runs on a "secured" intranet. The work station OS is Win XP Pro and the browser is IE 6. I am looking for an ActiveX control that I can use to get the user id of the person logged on to the client machine for logging purposes and that I can call/access from an html page.

Any ideas?

All help will be appreciated. Thanks
 
You can use wshshell to write .username, .computername and userdomain to (hidden) form fields and submit those data to the server before allowing access to secure info.
[tt]
var wshshell=new ActiveXObject("wscript.network");
//write to some (hidden) form field
with (document.formname) {
usernamefieldname.value=wshshell.username;
computernamefieldname.value=wshshell.computername;
userdomainfieldname.value=wshshell.userdomain;
}
wshshell=null;
[/tt]
As to security setting, you can request the audience to put the intranet secure site in their trust zone and set appropriate zone security. But, it would be appropriate too not to set a too low security level.

But you can sure have alternative by disabling anonymous login from the server. You should ask asp forum for detail.
 
Thanks tsuji.

This is my first step into ActiveX so I have a larger question. I understand the form & hidden field stuff I am just not sure where to put this code and how to get it to execute.

I really appreciate your help.
 
[1] Off-hand like this for automatic re-direction followed on the server based on data. Note that I name the object bad (not that it is fatal, it is easy to confused with another object I had in mind.)
[tt]
<script language="javascript>
function getcredential() {
var wsh[red]network[/red]=new ActiveXObject("wscript.network");
//write to some (hidden) form field
with (document.formname) {
usernamefieldname.value=wsh[red]network[/red].username;
computernamefieldname.value=wsh[red]network[/red].computername;
userdomainfieldname.value=wsh[red]network[/red].userdomain;
}
wsh[red]network[/red]=null;
document.formname.submit();
}
window.onload=getcredential;
</script>
[/tt]
[2] With the bare minimal body (as it would be automatically submitted data upon client's consent.) The re-direction functionality is scripted in the login.asp on the server.
[tt]
<body>
<div>
Please consent to the execution of a "unsafe" ActiveX.<br />
It is the standard wshnetwork control come originally with the windows OS.</br />
It is for the login to the secure area.</br />
</div>
<form name="formname" method="post" action="login.asp">
<input type="hidden" name="usernamefieldname" />
<input type="hidden" name="computernamefieldname" />
<input type="hidden" name="userdomainfieldname" />
</form>
</body>
[/tt]
[3] The message is of course largely to tailor to need.
 
That's absolutely wonderful tsuji. You are the MAN.

Thanks a bunch.
 
erratum
Thanks! Just to note a typo on <br /> (rather than <[red]/[/red]br />) at two places. (I typed it at real time.)
 
thanks for all



----------------------------------------------------------------------------------------------------------------

ÜCRETS?Z E-T?CARET OTOMASYON S?STEMLER? [URL unfurl="true"]www.netfirtina.com

----------------------------------------------------------------------------------------------------------------
 
tsuji -

Thanks for the correction, also left out the closing quote on "javascript".

Don't think I am nit picking. Your code was absolutely what was needed.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top