With Active Server Pages (ASP) you can generate custom audit records for precisely monitoring a specific Web site's security activity. For example, suppose you are interested in auditing the authentication activity of a restricted Web site. With ASP you can create a compact server-side script that you add to the Web site's logon page, which records only the authenticated account names of users who have accessed that site.
To create audit records using ASP<% 'Find the physical path for the file in the current directory. MainPath = Request.ServerVariables("PATH_TRANSLATED") 'Determine the path for the current page and then remove the 'name of the file from the path (leaving just the directory). Length = Len(MainPath) Do While (Mid(MainPath, Length, 1) <> "\") Length = Length - 1 Loop FilePath = left(MainPath, Length) LogFilePath = FilePath + "LogFile.log" 'Open the log file so that new log items can be appended to to previous items Application.Lock Set FileObject = Server.CreateObject("Scripting.FileSystemObject") Set OutStream=FileObject.OpenTextFile(LogFilePath, 8, TRUE) 'Define variables to be placed in log file. UserName=Trim(Request.ServerVariables("HTTP_LOGONUSER") ) If Len(UserName) < 2 Then UserName = "Anonymous" Host=Request.ServerVariables("REMOTE_HOST") IPAddr = Request.ServerVariables("REMOTE_ADDR") If Host <> IPAddr Then Host = Host + " (" + IPAddr + ")" 'Write the logging information to a text file OutStream.WriteLine UserName&" from "& Host &" visited "&MainPath& " at " & Time &" on " & Date OutStream.Close Set OutStream = Nothing Application.Unlock %>
Note If your .asp file does not contain content, such as text or images, the browser will not display any information.
Note The previous example script used the ASP server environment variables to collect information about user logon, host, and IP address information. You can extend the your own scripts by incorporating a variety of other available server variables, such as variables for detecting whether an HTTP request to your ASP page was handled over a secure communication port. For more information, see the Request Object.