システムエンジニアの技術メモ

ASP (Active Server Pages)

001. ServerVariables [環境変数]

ServerVariables コレクション
<%@ Language=VBScript CodePage=932 %>
<%
    On Error Resume Next
    Set WshShell = Server.CreateObject("WScript.Shell")

    '// Get nbtstat information
    strCMD = "cmd /c nbtstat -a " & Request.ServerVariables("REMOTE_HOST")
    Set objExec = WshShell.Exec(strCMD)

    strSTAT = Replace(objExec.StdOut.ReadAll, "$", " ")

    If InStr(strSTAT, "<00>") > 0 Then strCNM = Mid(strSTAT, InStr(strSTAT, "<00>") - 15, 15)
    If InStr(strSTAT, "MAC Address") > 0 Then strMAC = Mid(strSTAT, InStr(strSTAT, "MAC Address") + 14, 17)

    i = 1
    Do
        i = InStr(i, strSTAT, "<03>")
        If i = 0 Then Exit Do
        If strCNM <> Mid(strSTAT, i - 15, 15) Then
            strUID = Mid(strSTAT, i - 15, 15)
            Exit Do
        End If
        i = i + 1
    Loop
%>

<html>

<head>
    <title>ServerVariables [環境変数].asp</title>
</head>

<style type="text/css">
<!--
td {
    font-size: 13px;
    font-family: monospace;
    vertical-align: top;
    white-space: nowrap;
}
-->
</style>

<body>
<pre>
<table><tr><td>■ServerVariables</td><td width="100%"><hr></td></tr></table>
<table>
<%
    For Each i In Request.ServerVariables
        Response.Write "<tr><td>【</td><td>" & i & "</td><td>】</td><td>"
        Response.Write Replace(Request.ServerVariables(i), Chr(10), "<br>") & "</td></tr>"
    Next
%>
</table>

<table><tr><td>■Session objects</td><td width="100%"><hr></td></tr></table>
<table>
<tr><td>【</td><td>Session.SessionID</td><td>】</td><td><%=Session.SessionID%></td></tr>
<tr><td>【</td><td>Session.LCID</td><td>】</td><td><%=Session.LCID%></td></tr>
<tr><td>【</td><td>Session.Timeout</td><td>】</td><td><%=Session.Timeout%></td></tr>
<%
    Dim ary01(2): ary01(0) = "配列1": ary01(1) = "配列2": ary01(2) = "配列3":
    Session("ary01") = ary01
    Session("username") = "USER"
    Session("password") = "PASSWORD"

    For Each i In Session.Contents
        Response.Write "<tr><td>【</td><td>" & i & "</td><td>】</td><td>"
        If IsArray(Session.Contents(i)) Then
            For Each objArray In Session.Contents(i)
                Response.Write objArray & "<br>"
            Next
        Else
            Response.Write Session.Contents(i)
        End If
        Response.Write "</td></tr>"
    Next
%>
</table>

<table><tr><td>■nbtstat / client information</td><td width="100%"><hr></td></tr></table>
<table>
<tr><td>【</td><td>NBTSTAT_LOGON_USER</td><td>】</td><td><%=strUID%></td></tr>
<tr><td>【</td><td>NBTSTAT_COMPUTER</td><td>】</td><td><%=strCNM%></td></tr>
<tr><td>【</td><td>NBTSTAT_MAC_ADDRESS</td><td>】</td><td><%=strMAC%></td></tr>
</table>

</pre>
</body>

</html>