次の方法で共有


Visual Basic による ASP を使用する

ここでは、.NET Alerts サブスクリプション ミラーリング プロトコルを使用した Microsoft® .NET Alerts サブスクリプション サービスとの簡単な対話を示します。

BaseURLs.asp

このファイルを編集して、正しい URL を指すようにします。cTestSite は、.NET Alerts サブスクリプション サービスのリダイレクト先の基本 URL です。cNoteSite は、.NET Alerts サブスクリプション サービスの URL です。

<!--
cTestSite should specify the base URL of the directory that contains these sample pages on your Web server.
cNoteSite should specify the URL of the server to which you are submitting the subscription request.
The URL for the PREP subscription mirroring server will be provided when you register to become a .NET Alerts provider.
Include the trailing slash in both URLs.
-->

<%
  const cTestSite = "http://YourTestServer/"
  const cNoteSite = "https://ServerName/Alerts/"
%>

InputChange.asp

このページは、SubscriptionChange.asp に渡されるパラメータの入力に使用します。

<% OPTION explicit %>

<!-- #include file="BaseUrls.asp" -->

<html>
   <head>
      <title>InputChange.asp</title>
      <script language="javascript">

      function CheckForm()
      {
         var puidhigh = document.go.PUIDhigh.value;
         var puidlow = document.go.PUIDlow.value;
         var prepuidhigh = puidhigh.substring(0,2);
         var prepuidlow = puidlow.substring(0,2);
         var cpid = document.go.cp.value;
         var lcid = document.go.lcid.value;
         var bError;
         puidhigh = puidhigh.substring(2,puidhigh.length);
         puidlow = puidlow.substring(2,puidlow.length);

         bError = false;
         document.all.PUIDhighTEXT.innerHTML = "";
         document.all.PUIDlowTEXT.innerHTML = "";
         document.all.cpTEXT.innerHTML = "";
         document.all.lcidTEXT.innerHTML = "";
         if (puidhigh.search(/^[a-fA-F0-9]*$/) == -1 || puidhigh.length > 8 ||
            (prepuidhigh.toLowerCase() != "&h" && prepuidhigh.toLowerCase() != "0x") )
         {
            bError = true;
            document.all.PUIDhighTEXT.innerHTML = "<font color='red'>Invalid PUID High.</font>";
            document.go.PUIDhigh.focus();
         }
         else if (puidlow.search(/^[a-fA-F0-9]*$/) == -1 || puidlow.length > 8 ||
            (prepuidlow.toLowerCase() != "&h" && prepuidlow.toLowerCase() != "0x"))
         {
            bError = true;
            document.all.PUIDlowTEXT.innerHTML = "<font color='red'>Invalid PUID Low.</font>";
            document.go.PUIDlow.focus();
         }
         else if (cpid.search(/^[0-9]{1,9}$/) == -1 )
         {
            bError = true;
            document.all.cpTEXT.innerHTML = "<font color='red'>Invalid CP ID.</font>";
            document.go.cp.focus();
         }
         else if (lcid.search(/^[0-9]{4,6}$/) == -1 && lcid.length > 0)
         {
            bError = true;
            document.all.lcidTEXT.innerHTML = "<font color='red'>Invalid LCID.</font>";
            document.go.lcid.focus();
         }

         if (bError)
            return false;
         else
            document.go.submit();
      }

      </script>
   </head>

   <body>

      <DIV CLASS="clsDocBody">
         <h2 align=center>Input parameters for SubscriptionChange.asp
         </h2>

         <hr>
         <b>Note</b> Edit BaseUrls.asp to define the correct base URLs for the pages at this test site and the
         .NET Alerts routing engine. The current base URLs are:
         <br>
         <table>
            <tr><td align=right><b>Subscription server URL:</b></td><td><%=cNoteSite%></td></tr>
            <tr><td align=right><b>return URL (directory where these pages are stored):</b></td><td><%=cTestSite%></td></tr>
         </table>

         <hr>
         <form action="CallChange.asp" method="post" id="go" name="go">

            <table>
               <tr>
                  <td></td>
                  <td>
                     PUIDhigh and PUIDlow are the high and low numbers of the subscriber's .NET Passport Unique ID (PUID),
            respectively.
                     Normally you would get these values from the user's
            .NET Passport profile after authenticating the user. These values
                     are
            not input parameters to SubscriptionChange.asp;
            rather, they are used to calculate the MD5 content provider
            authentication
                     ticket that is passed to SubscriptionChange.asp.
            See CallChange.asp for the way in which the MD5 authentication ticket is built.
                 </td>
               </tr>
               <tr>
                  <td align=right><b>PUIDhigh:</b></td>
                  <td><input name=PUIDhigh type="text" size=20 value="0x01234567">&nbsp<span id="PUIDhighTEXT" name="PUIDhighTEXT"/><br></td>
               </tr>
               <tr>
                  <td align=right><b>PUIDlow:</b></td>
                  <td><input name=PUIDlow type="text" size=20 value="0x89abcdef">&nbsp<span id="PUIDlowTEXT" name="PUIDlowTEXT"/><br></td>
               </tr>

               <tr>
                  <td></td><td>
                     The password is provided by Microsoft at the time of the .NET Alerts provider's registration.
            This, along with the user's PUID and a time stamp,
                     is used to calculate
            the MD5 .NET Alerts provider authentication ticket that is passed to SubscriptionChange.asp in the cpa parameter.
                     <br>
                     <input type="checkbox" name="CheckPWD" ID="ChecKPWD" value="Checked">
                     Check the box to use your credentials installed in the registry
            by installsdkkey.exe.
                  </td>
               </tr>
               <tr>
                  <td align=right><b>password:</b></td>
                  <td><input name=password type="text" size=20 value="my_password"><br>
                  </td>
               </tr>
               <tr>
                  <td></td><td>
                  rtn is the return URL to which the subscription service will redirect when the request has been processed.
                  This parameter must
            be URL-encoded and must not contain parameters.
                  </td>
               </tr>
               <tr>
                  <td align=right><b>rtn:</b></td>
                  <td><input name=rtn type="text" size=80 value="<%=cTestSite & "DisplayChange.asp"%>"><br></td>
               </tr>

              <tr>
                 <td></td><td>
                 cp is the .NET Alerts Site ID, which is assigned by Microsoft at the time of the
            .NET Alerts
            provider's registration.
                 </td>
              </tr>
              <tr>
                 <td align=right><b>cp:</b></td>
                 <td><input name=cp type="text" size="20">&nbsp<span id="cpTEXT" name="cpTEXT"/><br></td>
             </tr>

             <tr>
                <td></td><td>
                    req specifies an action to be performed. The valid action specifiers are:
                    <ol>
                    <li>&quot;s&quot; to subscribe (that is, to create a new subscription or
                        update an existing subscription). </li>
                    <li>&quot;d&quot; to delete a subscription. </li>
                    </ol>
                    <p>For backward compatibility, the action code must be postfixed
                    with &quot;-100000000&quot;. For example, to delete a subscription, set req=d-100000000.
                </td>
             </tr>

             <tr>
                <td align=right><b>req:</b></td>
                <td><input name=req type="text" size=80 value="s-100000000" ><br></td>
             </tr>

             <tr>
                <td></td><td>
                    dbg is an optional parameter that specifies that any errors encountered
            by SubscriptionChange.asp should be
                    displayed in human-readable form
            by that page. Do not specify this parameter from a production site.
                    Specify "s" to display debug information only in the case of an error;
            any other non-blank value will display
                    debug information for both success and failure.
                </td>
              </tr>
              <tr>
                 <td align=right><b>dbg:</b></td>
                 <td><input name=dbg type="text" value="y" size="20"><br></td>
              </tr>
              <tr>
                 <td></td><td>
                    "lcid" is an optional parameter that specifies in which language you want the
                    policy creation pages to be displayed. lcid is in decimal value. en-us is 1033.
                 </td>
              </tr>
              <tr>
                 <td align=right><b>lcid:</b></td>
                 <td><input name=lcid type="text" value="" size="20">&nbsp<span id="lcidTEXT" name="lcidTEXT"/><br></td>
              </tr>
          </table>
      <p>
         <!--<input type="submit" value="Display Values on CallChange.asp" name=submit1>-->
         <input type="button" value="Display Values on CallChange.asp" onclick="CheckForm()" id=submit1 name=submit1>
      </form>

   </div>

</body>

CallChange.asp

このページでは、MSNOTIFY.DLL の NotificationsUtility オブジェクトで提供されるメソッドを使用して、.NET Alerts プロバイダの認証チケット (cpa) を計算します。その後、.NET Alerts サブスクリプション サーバー上の SubscriptionChange.asp の呼び出しに使用するパラメータ化された URL を表示します。

<% OPTION explicit %>

<%
   Response.Expires = -1442 ' negative number for global time issues
   Response.AddHeader "Cache-Control", "no-cache"
   Response.AddHeader "Pragma", "no-cache"
%>

<!-- #include file="BaseUrls.asp" -->

<html>
   <head>
      <title>InputChange.asp</title>
   </head>

   <body>

      <DIV CLASS="clsDocBody">

<%

  ' Calculate the .NET Alerts provider's authentication digest string.
  '
  ' The authentication string is a 32-byte hexadecimal string that contains the MD5 hash of:
  ' 1) the .NET Alerts provider's password.
  ' 2) the subscriber's PUID in the form of 0xhhhhhhhh:0xllllllll. (Letters must be lowercase.)
  ' 3) a Greenwich mean time date and time stamp in the form of yyyymmddhh.
  ' These strings are concatenated in this order.
  '
  ' SubscriptionChange.asp will match the current hour, but it will also match an hour
  ' before (if time is less than 30 minutes past the hour) or an hour later (if time is
  ' 30 minutes or more past the hour).
  '

   private function ps(s,l) ' prefix a string with zeros
      ps=string(l-len(s),"0") & s
   end function

   private function cp(s) ' change "0x" prefix to vbscript "&H"
      if left(s,2)="0x" then
         cp="&H" & right(s,len(s)-2)
      else
         cp=s
      end if
   end function

   dim NU, cpa, authPUID, authTime, authTimeString, szLCID,szFile,
   set NU = Server.CreateObject("MSNOTIFY.NotificationsUtility")
   authTime=NU.GetGMT() ' call MSNOTIFY dll to get current Greenwich mean time

   authTimeString _
      = year(authTime) _
      & ps(month(authTime),2) _
      & ps(day(authTime),2) _
      & ps(hour(authTime),2) ' get GMT date/time string to current hour

   authPuid = "0x" & ps(hex(cp(request("PUIDhigh"))),8) _
      & ":0x" & ps(hex(cp(request("PUIDlow"))),8) ' get user's PUID in string format

   if request("CheckPWD") = "Checked" then

      cpa = NU.GetCPA(authPuid) ' call MSNOTIFY dll to get a cpa

      Response.Write "Used credentials from registry <br>"
      Response.Write "authPuid=" & authPuid & "<br>"
   else

      cpa = NU.MD5Hash( request("password") & authPuid & authTimeString) ' call MSNOTIFY dll to create hash

      Response.Write "authTime=" & authTime & "<br>"
      Response.Write "authTimeString=" & authTimeString & "<br>"
      Response.Write "authPuid=" & authPuid & "<br>"

   end if

   '
   ' You can call SubscriptionChange.asp by building and redirecting to the parameterized call change URL
   ' or by submitting the parameters from a form. Examples of both methods appear below.
   '
   ' Response.Clear
   ' Response.Redirect(cNoteSite & "SubscriptionChange.asp" _
   ' & "?dbg=" & request("dbg") _
   ' & "&rtn=" & Server.URLEncode(request("rtn")) _
   ' & "&cp=" & request("cp") _
   ' & "&cpa=" & cpa _
   ' )
%>

         <h2 align=center>Call SubscriptionChange.asp</h2>

         <hr>
         The data entered results in the following set of parameters. Note that "rtn" is URL-encoded:
        <p>
<%
   szLCID = request("lcid")
   szFile = "SubscriptionChange.asp"
   if len(szLCID) > 0 then
      szFile = szFile & "?lcid="&szLCID
   end if
   Response.write "redirect to: " & cNoteSite & szFile & "<br>"
   Response.write "dbg=" & request("dbg") & "<br>"
   Response.write "rtn=" & Server.URLEncode(request("rtn")) & "<br>"
   Response.write "cp=" & request("cp") & "<br>"
   Response.write "req=" & request("req") & "<br>"
   Response.write "cpa=" & cpa & "<br>"
%>

         <form action="<%=cNoteSite & szFile%>" method="post" id="go" name="go">
            <input type=hidden name=dbg value="<%=request("dbg")%>">
            <input type=hidden name=rtn value="<%=request("rtn")%>">
            <input type=hidden name=cp value="<%=request("cp")%>">
            <input type=hidden name=req value="<%=request("req")%>">
            <input type=hidden name=cpa value="<%=cpa%>">
            <input type="submit" value="Call SubscriptionChange.asp" name=submit>
         </form>

      </div>
   </body>
</html>

DisplayChange.asp

このページでは、.NET Alerts サブスクリプション サービスからパラメータを受け取って表示します。

<% OPTION explicit %>

<%
   Response.Expires = -1442 ' negative number for global time issues
   Response.AddHeader "Cache-Control", "no-cache"
   Response.AddHeader "Pragma", "no-cache"
%>

<!-- #include file="BaseUrls.asp" -->

<html>
   <head>
   </head>

   <body>
      <DIV CLASS="clsDocBody">
         <H1><A NAME="H1_1328113603"></A>You have returned from the .NET Alerts subscription
            mirroring service</H1><HR SIZE="1"></HR>

         <%
            ' Decode the results of the SubscriptionChange redirection...
            if len(request("ce")) then%>
         <font color="darkred">
            The .NET Alerts subscription mirroring service returned an error, ce=<%=request("ce")%>
         </font>
         <%elseif request("req")="c" then%>
            <font color="darkgreen">
               The subscription was created.
            </font>
         <%elseif request("req")="d" then%>
            <font color="darkgreen">
               The subscription was deleted.
            </font>
         <%elseif request("req")="r" then%>
            <font color="darkgreen">
               The subscription existed and was read.
            </font>
         <%else%>
            <font color="darkgreen">
               The subscription existed and was modified.
            </font>
         <%end if%>
            <hr>
            Parameters returned by the .NET Alerts subscription mirroring service are:
          <br>
          <%

             dim strKey, strSubKey
             For Each strKey In Request.QueryString
                Response.Write "<b>" & strKey & "</b> = " & Request.QueryString(strKey) & "<BR>"
             Next
          %>
          <br>
          <%
             For Each strKey In Request.Form
                Response.Write "<b>" & strKey & "</b> = " & Request.Form(strKey) & "<BR>"
             Next
          %>
          <form action="InputChange.asp" method="get" id="form1" name="form1">
             <input type="submit" value="Go back to InputSubscriptionChange.asp" name=submit1>
          </form>
      </div>
</body></html>

  |