home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / ims.cab / smosec.asp < prev    next >
Text File  |  1997-10-20  |  13KB  |  490 lines

  1. <%
  2. '----------------------------------------------------------------------------
  3. '
  4. '
  5. '   File: smosec.asp
  6. '
  7. '   Description: Outbound security page
  8. '
  9. '   Copyright (C) 1997 Microsoft Corporation
  10. '
  11. '------------------------------------------------------------------------------
  12. %>
  13.  
  14. <% Response.Expires = 0 %>
  15.  
  16. <%
  17. REM LOCALIZATION
  18.  
  19. L_PAGETITLE_TEXT        = "Outbound Security"
  20. L_NOAUTH_TEXT            = "No authentication"
  21. L_CLEAR_TXT_AUTH_TEXT    = "Clear text authentication"
  22. L_WINDOWS_NT_CHALLENGE_TEXT    = "Windows NT Challenge/Response authentication"
  23. L_ACCOUNT_TEXT                = "Account:"
  24. L_WINDOWS_NT_ACCOUNT_TEXT        = "WindowsNTAccount:"
  25. L_TLSENCRYP_TEXT            = "TLS encryption"
  26. L_OK_TEXT                    = "OK"
  27. L_CANCEL_TEXT                = "Cancel"
  28. L_HELP_TEXT                    = "Help"
  29. L_CHANGE_TEXT                = "Change..."
  30. L_AUTHACCOUNT_TEXT            = "AuthenticationAccount"
  31. CHANGETXT_TEXT            = "change"
  32.  
  33. REM End LOCAIZATION
  34.  
  35. SAVE_TEXT        = "save"
  36. DOMAINS_TEXT    = "domain"
  37. UPDATE_TEXT        = "update"
  38.  
  39. SMTP_NO_ACTION        = 0        ' 0x00000000    
  40. SMTP_SSL            = 4        ' 0x00000004
  41. SMTP_AUTH_NTLM        = 128    ' 0x00000080
  42. SMTP_AUTH_CLEARTEXT    = 256    ' 0x00000100
  43.  
  44. REM UserName        Get's the userName that is logged on
  45. REM dpath            IIS path set by the Global.asa
  46. REM a                Action to be performed, blank for editing 'save' for saving the data
  47. REM siteInstance    Server instance
  48. REM sectype            type of security to edit, blank for delivery, 'domain' for domains
  49.  
  50. UserName        = Request("LOGON_USER")
  51. dpath            = Session("dpath") 
  52. a                = Request("a")
  53. siteInstance    = Request("ServerInstance")
  54. sectype            = Request("sectype")
  55. DomainName        = Request("DomainName")
  56.  
  57. RouteAction            = Request("newRouteAction")
  58. RouteUserName        = Request("txtRouteUserName")
  59. RoutePassword        = Request("txtRoutePassword")
  60. RouteActionString    = Request("txtRouteActionString")
  61.  
  62.  
  63. %>
  64. <!--#include file="smerrors.asp" -->
  65. <script language="javascript">
  66. <%
  67.  
  68. if (siteInstance = "") then
  69.     siteInstance = Session("ServerInstance")
  70. else
  71.     Session("ServerInstance") = siteInstance
  72. end if 
  73.  
  74. if (Session("svr") = "") then
  75.     Session("svr") = Request.ServerVariables("SERVER_NAME")
  76. end if
  77. svr            = UCase(Session("svr"))
  78.  
  79. if (dpath = "") then
  80.     dpath = "IIS://" & svr & "/SmtpSvc"
  81. end if
  82.  
  83. On Error Resume Next
  84. set smtpAdm    = GetObject(dpath)
  85. if (Err <> 0) then
  86.     szError = GetErrorMessage(Err) %>
  87.     alert("<% = szError %> : <% = Err %>");
  88. <%
  89. end if
  90. szServerString = dpath & "/" & siteInstance
  91.  
  92. On Error Resume Next
  93. set smtpServer = GetObject(szServerString) 
  94. if (Err <> 0) then 
  95.     szError = GetErrorMessage(Err) %>
  96.     alert("<% = szError %> : <% = Err %>");
  97. <%
  98. end if 
  99.  
  100. szDomainString = szServerString & "/" & "Domain"
  101. szDomainClassString = "IIsSmtpDomain"
  102. Dim smtpDomain
  103.  
  104. if (sectype = DOMAINS_TEXT) then
  105.     On Error Resume Next
  106.     set smtpDomain = GetObject(szDomainString & "/" & DomainName)
  107.     if (Err <> 0) then
  108.         szError = GetErrorMessage(Err) %>
  109.         alert("<% = szError %> : <% = Err %>");
  110. <%    end if 
  111. end if
  112.  
  113. '----------------------------------------------------------------------------
  114. '
  115. '    If we are saving then check all the variables
  116. '
  117. '----------------------------------------------------------------------------
  118.  
  119. if (a = SAVE_TEXT) then
  120.     '
  121.     '    Check to see which bits are set
  122.     '
  123.  
  124.     if (RouteAction And SMTP_NO_ACTION) then 
  125.         RouteUserName = ""
  126.         RoutePassword = ""
  127.     end if 
  128.     if ((RouteAction And SMTP_AUTH_CLEARTEXT) And ((InStr(RouteUserName, "\")) <> 0)) then
  129.         RouteUserName = ""
  130.     end if
  131.  
  132.     if (sectype    = DOMAINS_TEXT) then
  133.  
  134.         smtpDomain.RouteUserName        = RouteUserName
  135.         smtpDomain.RoutePassword        = RoutePassword
  136.         smtpDomain.RouteActionString    = RouteActionString
  137.  
  138.         On Error Resume Next
  139.         smtpDomain.SetInfo
  140.         if (Err <> 0) then
  141.             szError = GetErrorMessage(Err) %>
  142.             alert("<% = szError %> : <% = Err %>");
  143. <%        end if
  144.  
  145.     else
  146.         'unflag all options
  147.         szBitMask = smtpServer.RouteAction
  148.         szBitMask = szBitMask AND NOT SMTP_AUTH_NTLM
  149.         szBitMask = szBitMask AND NOT SMTP_AUTH_CLEARTEXT
  150.         szBitMask = szBitMask AND NOT SMTP_SSL
  151.  
  152.         'set bitmask
  153.         szBitMask = szBitMask OR RouteAction
  154.         
  155.         smtpServer.RouteAction = szBitMask
  156.         smtpServer.RouteUserName = RouteUserName
  157.         smtpServer.RoutePassword = RoutePassword
  158.         smtpServer.RouteActionString = RouteActionString
  159.  
  160.         On Error Resume Next
  161.         smtpServer.SetInfo
  162.         if (Err <> 0) then
  163.             szError = GetErrorMessage(Err) %>
  164.             alert("<% = szError %> : <% = Err %>");
  165. <%        end if
  166.     end if
  167.  
  168. elseif (a <> UPDATE_TEXT) then
  169.     if (sectype    = DOMAINS_TEXT) then
  170.         RouteActionString    = smtpDomain.RouteActionString
  171.         RouteAction            = smtpDomain.RouteAction
  172.         RouteUserName        = smtpDomain.RouteUserName
  173.         RoutePassword        = smtpDomain.RoutePassword %>
  174. <%
  175.  
  176.     else
  177.         RouteAction            = smtpServer.RouteAction
  178.         RouteUserName        = smtpServer.RouteUserName
  179.         RoutePassword        = smtpServer.RoutePassword
  180.     end if
  181.  
  182.  
  183. end if
  184. %>
  185. </script>
  186. <HTML>
  187. <HEAD>
  188.  
  189. <% if (a <> SAVE_TEXT) then %>
  190. <script language="javascript">
  191. function onOK()
  192. {
  193.     uform = document.userform;
  194.     uform.a.value = "<% = SAVE_TEXT %>";
  195.     GetRouteAction();
  196.  
  197.     uform.submit();
  198.  
  199. }
  200.  
  201.  
  202. <% REM Javascript function helpBox %>
  203. function helpBox() 
  204. {
  205.     window.open("help/smosech.htm","<% = L_HELP_TEXT %>","toolbar=no,scrollbars=yes,directories=no,menubar=no,width=450,height=450");
  206. }
  207.  
  208. function Initalize()
  209. {
  210.     uform = document.userform;
  211. <%    
  212.     szBitMask    = RouteAction 
  213.     iLength        = Len(szBitMask)
  214.     icomp        = 0
  215.     icomp = szBitMask And SMTP_NO_ACTION
  216.     if (icomp = 0) then %>
  217.         uform.rdoAutType[0].checked = true;
  218. <%    end if
  219.     
  220.     icomp = 0
  221.     icomp = szBitMask And SMTP_SSL
  222.     if (icomp) then %>
  223.         uform.chkTLS.checked = true;
  224. <%  end if 
  225.     
  226.     icomp = 0
  227.     icomp = szBitMask And SMTP_AUTH_NTLM
  228.     if (icomp) then %>
  229.         uform.rdoAutType[2].checked = true;
  230. <%    end if
  231.  
  232.     icomp = 0
  233.     icomp = szBitMask And SMTP_AUTH_CLEARTEXT
  234.     if (icomp) then %>
  235.         uform.rdoAutType[1].checked = true;
  236. <%    end if %>
  237.  
  238.  
  239. }
  240.  
  241. function GetRouteAction()
  242. {
  243.     
  244.     uform = document.userform;
  245.     var szBitMask = <% = RouteAction %>;
  246.     szBitMask = szBitMask & ~<% = SMTP_AUTH_NTLM %>;
  247.     szBitMask = szBitMask & ~<% = SMTP_AUTH_CLEARTEXT %>;
  248.     szBitMask = szBitMask & ~<% = SMTP_SSL %>;
  249.  
  250.     if (uform.rdoAutType[0].checked)
  251.     {
  252.         szBitMask = szBitMask | <% = SMTP_NO_ACTION %>;
  253.     }
  254.  
  255.     if (uform.rdoAutType[2].checked)
  256.     {
  257.         
  258.         szBitMask = szBitMask | <% = SMTP_AUTH_NTLM %>;
  259.     }
  260.     
  261.     if (uform.rdoAutType[1].checked)
  262.     {
  263.         szBitMask = szBitMask | <% = SMTP_AUTH_CLEARTEXT %>;
  264.     }
  265.     
  266.     if (uform.chkTLS.checked)
  267.     {
  268.         szBitMask = szBitMask | <% = SMTP_SSL %>;
  269.     }
  270.     
  271.     
  272.     uform.newRouteAction.value = szBitMask;    
  273. }
  274.  
  275. function authDialog(szType)
  276. {
  277.     var width = 375;
  278.     var height = 260;
  279.     uform = document.userform;
  280.     uform.txtRoutePassword.value = "";
  281.     uform.txtRouteUserName.value = "";
  282.  
  283.     <% if Instr(Request.ServerVariables("HTTP_USER_AGENT"),"MSIE") then %>
  284.     <% else %>
  285.         width = width + 25;
  286.         height = height + 25;
  287.     <% end if %>
  288.  
  289.     var title = "<% = CHANGETXT_TEXT %>";
  290.     <% RouteUserName = Replace(RouteUserName, "\", "%5C%5C") %>
  291.     var path = "smAu.asp?svr=<% = svr %>&ServerInstance=<% = siteInstance %>";
  292.     var route = "&RouteUserName=<% = RouteUserName %>";
  293.     if (szType == "clear")
  294.     {
  295.         //Clear Text Authentication
  296.             
  297.         uform.rdoAutType[1].checked = true;
  298.         path = path + "&AuthType=clear" + route;
  299.  
  300.     }
  301.     else
  302.     {
  303.         //NT Challenge/Response
  304.         uform.rdoAutType[2].checked = true;
  305.         path = path + "&AuthType=NT" + route;
  306.         GetRouteAction();
  307.     }
  308.     
  309.     GetRouteAction();
  310.     var winstr = "toolbar=no,scrollbars=no,directories=no,menubar=no,width="+width+",height="+height+",resizable=no";
  311.     var accountbox = window.open(path,title,winstr);
  312.     if(accountbox != null)
  313.     {
  314.         if (accountbox.opener == null)
  315.         {
  316.             accountbox.opener = self;
  317.         }
  318.     }
  319.     <% RouteUserName = Replace(RouteUserName, "%5C%5C", "\") %>
  320.     GetRouteAction();
  321. }
  322.  
  323. function myTest()
  324. {
  325.     GetRouteAction();
  326. }
  327.  
  328. </script>
  329. <% end if %>
  330. <TITLE><% = L_PAGETITLE_TEXT %></TITLE>
  331. </HEAD>
  332. <% if (a = SAVE_TEXT) then %>
  333. <script language="javascript">
  334. <% if (secType = DOMAINS_TEXT) then %>
  335.     var szBitMask = <% = smtpDomain.RouteAction %>
  336.     wform = opener.document.userform;
  337.     var szBitMask = wform.newActionType.value;
  338.     szBitMask = szBitMask & ~<% = SMTP_AUTH_NTLM %>;
  339.     szBitMask = szBitMask & ~<% = SMTP_AUTH_CLEARTEXT %>;
  340.     szBitMask = szBitMask & ~<% = SMTP_SSL %>;
  341.  
  342.     wform.newActionType.value = szBitMask;
  343.     wform.newActionType.value = wform.newActionType.value | <% = RouteAction %>;
  344. <% end if %>
  345. </script>
  346.     <BODY background="images\black.gif" BGCOLOR="#CCCCCC" TEXT="#000000" TOPMARGIN=15 LINK="#000000" VLINK="#000000" ALINK="#000000" onLoad="close();">
  347. <% else %>
  348.     <BODY background="images\black.gif" BGCOLOR="#CCCCCC" TEXT="#000000" TOPMARGIN=15 LINK="#000000" VLINK="#000000" ALINK="#000000">
  349. <% end if %>
  350. <% if (a <> SAVE_TEXT) then %>
  351. <FORM NAME="userform" ACTION="smosec.asp"  METHOD="post">
  352.  
  353. <INPUT TYPE="hidden" NAME="a"                        VALUE="<% = a %>">
  354. <input type="hidden" name="newRouteAction"            value="<% = RouteAction %>">
  355. <input type="hidden" name="txtRoutePassword"        value="<% = RoutePassword %>">
  356. <input type="hidden" name="txtRouteActionString"    value="<% = RouteActionString %>">
  357. <input type="hidden" name="txtRouteUserName"        value="<% = RouteUserName %>">
  358. <input type="hidden" name="DomainName"                value="<% = DomainName %>">
  359. <input type="hidden" name="secType"                    value="<% = secType %>">
  360. <TABLE BORDER="1" BGCOLOR="#CCCCCC" WIDTH="100%" cellpadding="10">
  361. <TR><TD>
  362.     <TABLE BORDER="0"  WIDTH="100%" CELLPADDING="2" CELLSPACING="2">
  363.     <TR>
  364.         <TD colspan="3">
  365.             <FONT FACE="Arial" SIZE=2>
  366.             <input type="radio" name="rdoAutType" value="<% = L_NOAUTH_TEXT %>" onClick="GetRouteAction();">
  367.              <% = L_NOAUTH_TEXT %>
  368.             </font>
  369.         </TD>
  370.     </TR><TR>
  371.         <TD colspan="3">
  372.             <FONT FACE="Arial" SIZE=2>
  373.             <input type="radio" name="rdoAutType" value="<% = L_CLEAR_TXT_AUTH_TEXT %>" onClick="GetRouteAction();">
  374.              <% = L_CLEAR_TXT_AUTH_TEXT %>
  375.             </font>
  376.         </TD>
  377.     </TR><TR>
  378.         <TD colspan="2" width="75%">
  379.             <FONT FACE="Arial" SIZE=2>
  380.              <% = L_ACCOUNT_TEXT %> 
  381.             <% if (Mid(Hex(RouteAction), 1, 1) = "1") then %>
  382.                 <% = RouteUserName %>
  383.             <% else %>
  384.                  
  385.             <% end if %>
  386.             </font>
  387.         </td><td>
  388.             <FONT FACE="Arial" SIZE=2>
  389.              <INPUT NAME="btnChange" TYPE="button" VALUE="<% = L_CHANGE_TEXT %>" size="40" OnClick="authDialog('clear');">
  390.             </font>
  391.         </TD>
  392.     </TR><TR>
  393.         <TD colspan="3" height="1">
  394.              
  395.         </TD>
  396.     </TR><TR>
  397.         <TD COLSPAN="3">
  398.             <FONT FACE="Arial" SIZE=2>
  399.             <input type="radio" name="rdoAutType" value="<% = L_WINDOWS_NT_CHALLENGE_TEXT %>" onClick="GetRouteAction();">
  400.              <% = L_WINDOWS_NT_CHALLENGE_TEXT %>
  401.             </font>
  402.         </TD>
  403.     </TR><TR>
  404.         <TD colspan="2">
  405.             <FONT FACE="Arial" SIZE=2>
  406.              <% = L_WINDOWS_NT_ACCOUNT_TEXT %> 
  407.             <% if (Mid(Hex(RouteAction), 1, 1) = "8") then %>
  408.                 <% = RouteUserName %>
  409.             <% else %>
  410.                  
  411.             <% end if %>
  412.             </font>
  413.         </td><td>
  414.             <FONT FACE="Arial" SIZE=2>
  415.              <INPUT NAME="btnChange" TYPE="button" VALUE="<% = L_CHANGE_TEXT %>" size="40" OnClick="authDialog('NT');">
  416.             </font>
  417.         </TD>
  418.  
  419.     </TR><TR>
  420.         <TD colspan="3">
  421.             <FONT FACE="Arial" SIZE=2>
  422.             <input TYPE="CHECKBOX" Name="chkTLS" VALUE="<% = L_TLSENCRYP_TEXT %>" onClick="GetRouteAction();">
  423.              <% = L_TLSENCRYP_TEXT %>
  424.         </TD>
  425.     </TR>
  426.     </table>
  427. </TD></TR>
  428. </TABLE>
  429.  
  430.  
  431. <P>
  432. <TABLE ALIGN="right" BORDER=0 CELLPADDING=2 CELLSPACING=2>
  433.  
  434. <TR>
  435.     <TD>
  436.     <TABLE VALIGN="top" BORDER=0 CELLPADDING=5 CELLSPACING=0 BGCOLOR="#FFCC00">
  437.         <TR>
  438.             <TD VALIGN="middle">
  439.                 <FONT FACE="Arial" SIZE=2>
  440.                 <B><A HREF="javascript:onOK();">
  441.                 <IMG SRC="images/gnicok.gif" BORDER=0 ALIGN="top" HEIGHT=16 WIDTH=16></A>
  442.                 <A HREF="javascript:onOK();"><% = L_OK_TEXT%></A></B>
  443.                 </FONT>
  444.             </TD>    
  445.         </TR>
  446.         
  447.     </TABLE>
  448.     </TD>
  449.  
  450.     <TD>
  451.     <TABLE VALIGN="top" BORDER=0 CELLPADDING=5 CELLSPACING=0 BGCOLOR="#FFCC00">
  452.         <TR>
  453.             <TD VALIGN="middle">
  454.                 <FONT FACE="Arial" SIZE=2>
  455.                 <B><A HREF="javascript:close();">
  456.                 <IMG SRC="images/gniccncl.gif" BORDER=0 ALIGN="top" HEIGHT=16 WIDTH=16></A>
  457.                 <A HREF="javascript:close();"><% = L_CANCEL_TEXT %></A></B>
  458.                 </FONT>
  459.             </TD>    
  460.         </TR>
  461.     </TABLE>
  462.     </TD>
  463.     
  464.     <TD>
  465.     <TABLE VALIGN="top" BORDER=0 CELLPADDING=5 CELLSPACING=0 BGCOLOR="#FFCC00">
  466.         <TR>
  467.             <TD VALIGN="middle">
  468.                 <FONT FACE="Arial" SIZE=2><A HREF="javascript:helpBox();">
  469.                 <IMG SRC="images/gnichelp.gif" BORDER=0 ALIGN="top" HEIGHT=16 WIDTH=16></A>
  470.                 <B><A HREF="javascript:helpBox();"><% = L_HELP_TEXT %></A></B>
  471.                 </FONT>
  472.             </TD>    
  473.         </TR>
  474.     </TABLE>
  475.     </TD>
  476.     
  477.     <TD> </TD>
  478. </TR>
  479. </TABLE>
  480.  
  481. </FORM>
  482. <script language="javascript">
  483.     Initalize();
  484.     GetRouteAction();
  485.  
  486. </script>
  487. <% end if %>
  488. </BODY>
  489. </HTML>
  490.