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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need user name at client

Status
Not open for further replies.

dmcdivitt

Programmer
Jan 28, 2003
5
US
I need to retrieve the client logged-in user name and pass that to the server. A hidden field was added, so when posted to the server it can contain the info. The difficulty is getting the info. I'm proficient at VB6, but don't have that where I am, so I cannot make a component, register it, and create an object in vbscript. I do have all the express stuff installed. I made a DLL with VB Express, but it won't register. Help would be appreciated. Thanks
 
Is this an HTML page with a form that hosts VBScript?

If so you should be able to use the WshNetwork object:
Code:
<HTML>
  <HEAD>
    <SCRIPT language="VBScript">
      Option Explicit

      Sub window_onload()
        spnUser.innerText = CreateObject("WScript.Network").UserName
      End Sub
    </SCRIPT>
  </HEAD>
  <BODY>
    <P>User Name: <SPAN id=spnUser></SPAN></P>
  </BODY>
</HTML>
Note that this will result in security warnings that the user must ok unless you have some very liberal browser security settings.
 
I posted my original message from work. I have VB6 on order (because I like it), but it's a big bureaucratic agency and stuff doesn't happen very fast. At home I wrote a simple OCX with one string function output. In the HTML I put the following:

<HTML>
<HEAD>
<OBJECT id=UN codeBase=WebUsername.ocx classid=clsid:4BAA63AE-9C9C-4BC6-8EB7-B99060599519 VIEWASTEXT>
</OBJECT>
<SCRIPT language=vbscript id=clientEventHandlersVBS>
<!--
Sub window_onload
document.write(UN.username)
End Sub
-->
</SCRIPT>
</HEAD>
<BODY >
</BODY></HTML>

I copied this from another project and got the clsid from the registry after compiling the control. After compiling I unregistered the control, then placed the OCX file on the desktop next to my test HTML file. I ran the test HTML file and it worked. Also, when the page rendered, the OCX was copied to Windows\Downloaded_Program_Files, as if downloaded from the internet.

I did get the same security warning I got when I did the WShell example. I want IE to give me the information bar at the top and give me the opportunity to download the ActiveX control.

So I unregistered the control and deleted it, then I uploaded the test HTML and the OCX file to my personal web page. When I tried to run the test HTML there, I got the information bar at the top, but then I got a message saying Microsoft could not verify the publisher, and it was blocked. If I saw the information bar, and I allowed the ActiveX control to be installed, I thought it was supposed to go ahead and do that. What's the deal?

When I put this in production I don't mind the info bar being there, but I do need the ActiveX to install. How can I get it to do that? Thanks
 
No need for that. Just use ASP. Assuming you are use NT Authentication and have removed anonymous access then you could simply use:

Code:
<% 
    Response.Write Request.ServerVariables("LOGON_USER") 
    ' or 
    Response.Write Request.ServerVariables("AUTH_USER") 
%>

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
How cool! Thank you very much. Exactly what I need!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top