Vb script problems in asp

I am trying to get this code to work in an asp page. when the user clicks the OnClick button, it will move them to this page, which will create a file to store that username and runtime. So far, when this code works, it will create a "userinfo.flag" file, but it will not write user data. Basically, I am not collecting user data correctly.

<%
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set NewTextFile = FSO.OpenTextFile(server.mappath("UserInfo.flag"),2,true)
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "User Name = " & WshNetwork.UserName
NewTextFile.WriteLine("user:")
NewTextFile.WriteLine(WshNetwork.userName)
NewTextFile.WriteLine(Now)
NewTextFile.Close
Set NewTextFile = Nothing
Set FSO = Nothing

%>

<HTML>
<HEAD>
<TITLE>TEST PAGE</TITLE>
</HEAD>
</HTML>

      

0


source to share


1 answer


When working in the .asp environment, you do not have all the same globals available in the .vbs environment. Here are some things:

  • Do not use the WshNetwork object to find information about a user. This information (if the user is authenticated) is available inRequest.ServerVariables["AUTH_USER"]

  • Use Response.Write

    insteadWScript.Echo



This should get the correct user information.

0


source







All Articles