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

  1. <%
  2. '----------------------------------------------------------------------------
  3. '
  4. '   File: smdomhd.asp
  5. '
  6. '   Description: Header file Domains page for SMTP Web Admin.  This page counts
  7. '                and gets the information from all the domains in the Service.  Puts
  8. '                this information into a javascript array so it can be used
  9. '
  10. '   Copyright (C) 1997 Microsoft Corporation
  11. '
  12. '------------------------------------------------------------------------------%>
  13.  
  14. <% Response.Expires = 0 %>
  15. <%
  16.  
  17. L_PAGETITLE_TEXT        = "Microsoft SMTP Server Administration" 
  18. L_DOMAINNAME_TEXT        = "Domain Name:" 
  19. L_DOMAINSON_TEXT        = "Domains on" 
  20. L_TYPE_TEXT                = "Type:"
  21.  
  22. L_DEFAULTLOCAL_TEXT        = "Default Local"
  23. L_NORMALLOCAL_TEXT        = "Normal Local"
  24. L_ALIASLOCAL_TEXT        = "Alias Local"
  25. L_REMOTE_TEXT            = "Remote"
  26.  
  27. L_CANNOT_REMV_DOMAIN_TEXT        = "Cannot remove domain. A minimum of one domain is required."
  28. L_CONFIRM_REMV_DEFAULT_TEXT        = "If you remove the default Domain, you may not be able to configure the server in the future. Are you sure you want to remove the default Domain?"
  29. L_CONFIRM_REMV_DOMAIN_TEXT        = "Are you sure you want to remove this Domain?"
  30. L_CANNOT_REMOVE_DEFAULT_ERRORMESSAGE = "You cannot remove the default domain.  To remove the default domain you must make another domain the default."
  31.  
  32.  
  33. '-------------------------------------------------------------------------------
  34. '
  35. '    BitMask Values
  36. '
  37. '-------------------------------------------------------------------------------
  38. %>
  39. <% SMTP_DROP         = 1 REM local, norma w/non-empty drop dir %>
  40. <% SMTP_SMARTHOST     = 2 REM remote w/ UseSSL not checked %>
  41. <% SMTP_SSL         = 4 REM remote w/ UseSSL checked %>
  42. <% SMTP_ALIAS        = 16 REM local, alias %>
  43. <% SMTP_DELIVER        = 32 REM local, normal w/ empty drop dir %>
  44. <% SMTP_DEFAULT        = 64 REM local, default %>
  45.  
  46. <!--#include file="smerrors.asp" -->
  47.  
  48. <% REM Domians Page head frame (in frameset with head, list) %>
  49.  
  50. <% REM Get variables %>
  51. <% REM svr = Server name %>
  52. <% REM a = Action to be performed by server-side code (remove) %>
  53. <% REM SelectedDom = Domain edited by smdired.asp %>
  54.  
  55. <% svr = Session("svr") %>
  56. <% a = Request("a") %>
  57. <% SelectedDom = Request("SelectedDom")
  58. ServerInstance = Session("ServiceInstance")
  59. Session("ServiceInstance") = ServerInstance
  60.  
  61. if (Session("svr") = "") then
  62.     Session("svr") = Request.ServerVariables("SERVER_NAME")
  63. end if
  64. svr            = UCase(Session("svr"))
  65.  
  66. if (dpath = "") then
  67.     dpath = "IIS://" & svr & "/SmtpSvc"
  68. end if
  69. Session("dpath") = dpath
  70.  
  71. szServerString = dpath & "/" & ServerInstance
  72. szDomainString = szServerString & "/" & "Domain"
  73. szDomainClassString = "IIsSmtpDomain"
  74.  
  75. %>
  76. <% REM Index of Domian to Remove %>
  77. <% removeIndex = Request("removeIndex") %>
  78. <% REM Include _cnst file to force logon by anonymous users (if access denied, body of file ignored) %>
  79.  
  80. <!--#include file="_cnst.asp" -->
  81. <script language="javascript">
  82. <% if (cont = true) then %>
  83. <%
  84. On Error Resume Next
  85. Set admin = GetObject(dpath)
  86. if (Err <> 0) then
  87.     szError = GetErrorMessage(Err) %>
  88.     alert("<% = szError %>");
  89. <% end if %>
  90.  
  91. <% REM Instantiate Virtual Server object %>
  92. <% On Error Resume Next %>
  93. <% Set VServer = GetObject(szServerString) %>
  94. <% if (Err <> 0) then 
  95.     szError = GetErrorMessage(Err) %>
  96.     alert("<% = szError %>");
  97. <% end if %>
  98.  
  99. <% REM Get pointer to Domains %>
  100. <% On Error Resume Next %>
  101. <% set smtpDomain = GetObject(szDomainString) %>
  102. <% if (Err <> 0) then 
  103.     szError = GetErrorMessage(Err) %>
  104.     alert("<% = szError %>");
  105. <% end if %>
  106.  
  107. <% REM Enumerate Domains 
  108. Dim szDomains() REM Arry to hold domain names
  109.  
  110. iCount = 0
  111. for each child in smtpDomain
  112.     if (child.KeyType = szDomainClassString) then
  113.         iCount = iCount + 1
  114.     end if
  115. next 
  116.  
  117. ReDim szDomains(iCount)
  118. iLoop = 0 
  119. szDomains(0) = VServer.DefaultDomain
  120. for each child in smtpDomain
  121.     if (child.KeyType = szDomainClassString) then
  122.         iLoop = iLoop + 1
  123.         szDomains(iLoop) = child.name
  124.         if (child.name = "") then
  125.             szDomains(iLoop) = " "
  126.         end if
  127.     end if
  128. next
  129. %>
  130.  
  131. <% REM Perform remove action %>
  132.  
  133. <% if (a = "remove") then %>
  134. <%
  135.     szDomainToRemove = szDomains(removeIndex) %>
  136.     <% On Error Resume Next %>    
  137.     <% smtpDomain.Delete szDomainClassString, szDomainToRemove %>
  138.         <% if (Err <> 0) then
  139.             szError = GetErrorMessage(Err) %>
  140.             alert("<% = szError %> : Line #129");
  141.     <% end if %>
  142.  
  143.     <% On Error Resume Next %>    
  144.     <% smtpDomain.SetInfo %>    
  145.     <% if (Err <> 0) then
  146.         szError = GetErrorMessage(Err) %>
  147.         alert("<% = szError %> : Line #137");
  148.     <% end if %>
  149.  
  150. <% end if %>
  151. </script>
  152. <HTML>
  153. <HEAD>
  154. <TITLE><%= L_PAGETITLE_TEXT %></TITLE>
  155.  
  156. <SCRIPT LANGUAGE="javascript">
  157.  
  158. <% REM Create uForm object and methods %>
  159.  
  160.     var uForm = new Object();
  161.     uForm.itemList = new Array();
  162.     uForm.DirHome = "false";
  163.     uForm.selectedItem = 0;
  164.     uForm.selectItem = selectItem;
  165.     uForm.addItem = addItem;
  166.     uForm.removeItem = removeItem;
  167.     uForm.editItem = editItem;
  168.  
  169. <% REM Get count of Domains
  170. iCount = 0
  171. for each child in smtpDomain
  172.     if (child.KeyType = szDomainClassString) then
  173.         iCount = iCount + 1
  174.     end if
  175. next 
  176.  
  177. ReDim szDomains(iCount)
  178. iLoop = 0 
  179. szDomains(0) = VServer.DefaultDomain
  180. for each child in smtpDomain
  181.     if (child.KeyType = szDomainClassString) then
  182.         iLoop = iLoop + 1
  183.         szDomains(iLoop) = child.name
  184.         if (child.name = "") then
  185.             szDomains(iLoop) = " "
  186.         end if
  187.     end if
  188. next 
  189.  
  190. low = LBound(szDomains)
  191. high = HBound(szDomains)
  192.  
  193. iNumOfDomains = iCount + 1 %>
  194.  
  195.  
  196.  
  197. <% if (iNumOfDomains = 1) then %>
  198.     uForm.selectedItem = 0;
  199. <% end if %>
  200.  
  201. <% For i = 0 to (iNumOfDomains - 1) %>
  202. <%
  203.     if (i = 0) then
  204.         DomainName = VServer.DefaultDomain
  205.         actiontype = SMTP_DEFAULT
  206.     else
  207.         set myDomain = GetObject(szDomainString & "/" & szDomains(i))
  208.         DomainName = myDomain.Name
  209.         actionType = myDomain.RouteAction
  210.     end if
  211.  
  212.     icomp        = 0
  213.     icomp = actionType And SMTP_DROP
  214.     if (icomp) then
  215.         Domaintype = L_NORMALLOCAL_TEXT
  216.     end if
  217.  
  218.     icomp        = 0
  219.     icomp = actionType And SMTP_SMARTHOST
  220.     if (icomp) then
  221.         Domaintype = L_REMOTE_TEXT
  222.     end if
  223.  
  224.     icomp        = 0
  225.     icomp = actionType And SMTP_SSL
  226.     if (icomp) then
  227.         Domaintype = L_REMOTE_TEXT
  228.     end if
  229.  
  230.     icomp        = 0
  231.     icomp = actionType And SMTP_ALIAS
  232.     if (icomp) then
  233.         Domaintype = L_ALIASLOCAL_TEXT
  234.     end if
  235.  
  236.     icomp        = 0
  237.     icomp = actionType And SMTP_DELIVER
  238.     if (icomp) then
  239.         Domaintype = L_NORMALLOCAL_TEXT
  240.     end if
  241.  
  242.     icomp        = 0
  243.     icomp = actionType And SMTP_DEFAULT
  244.     if (icomp) then
  245.         Domaintype = L_DEFAULTLOCAL_TEXT
  246.     end if
  247.             
  248. %>
  249.  
  250.     <% REM SelectedDom variable (passed from pop-up) indicates which item had been selected before page was reloaded %>
  251.     <% REM If SelectedDom equals current Domainname, set selectedItem variable to current index %>
  252.  
  253.     <% if ((DomainName = Request("SelectedDom")) AND (Request("SelectedDom") <> "")) then %>
  254.     uForm.selectedItem = <% = i %>;
  255.     <% end if %>
  256.  
  257.     uForm.itemList[<% = i %>] = new Object();
  258.     uForm.itemList[<% = i %>].DomDomainName = "<% = DomainName %>";
  259.     uForm.itemList[<% = i %>].DomainType = "<% = Domaintype %>";
  260.     
  261. <% Next %>
  262.  
  263.  
  264. <% REM Determine browser to set pop-up window size %>
  265.  
  266. <% if Instr(Request.ServerVariables("HTTP_USER_AGENT"),"IE") then %>
  267.     var winstr = "width=420,height=560,directories=no,status=no,scrollbars=auto,resize=no";
  268. <% else %>
  269.     var winstr = "width=450,height=580,directories=no,status=no,scrollbars=auto,resize=no";
  270. <% end if %>
  271.  
  272. <% REM Javascript function selectItem changes selectedItem value, reloads list at specified position %>
  273.  
  274.     function selectItem(index) 
  275.     {
  276.         uForm.selectedItem = index;
  277.         parent.list.location = "smdomls.asp"
  278.     }
  279.  
  280.  
  281.  
  282. <% REM Javascript function addItem opens pop-up window %>
  283. <% REM DirHome variable (true/false) specifies whether a home directory already exists %>
  284.  
  285.     function addItem() 
  286.     {
  287.         winstr = "width=420,height=560,directories=no,status=no,scrollbars=auto,resize=no";
  288.         win = window.open("smdomed.asp?a=new&svr=<% = svr %>&ServiceInstance=<% = ServerInstance %>&DirHome=" + uForm.DirHome,"PropWindow",winstr);
  289.         if (win.opener == null) 
  290.         {
  291.             win.opener = self;
  292.         }
  293.     }
  294.  
  295.  
  296. <% REM Javascript function removeItem displays confirm, reloads head frame with "a=remove" parameter %>
  297. <% REM Displays alert message if user attempts to remove last directory; displays confirm if user attempts to remove home directory %>
  298.  
  299.     function removeItem() 
  300.     {
  301.         index = uForm.selectedItem;
  302.         DomainName = uForm.itemList[index].DomDomainName;
  303.              
  304.         if (uForm.itemList.length == 1) 
  305.         {
  306.             alert("<%= L_CANNOT_REMV_DOMAIN_TEXT %>");
  307.             return;
  308.         }
  309.         else if(index == 0)
  310.         {
  311.             alert("<% = L_CANNOT_REMOVE_DEFAULT_ERRORMESSAGE %>");
  312.             return;
  313.  
  314.         }
  315.         else 
  316.         {
  317.             index = uForm.selectedItem;
  318.             var DomainName = uForm.itemList[index].DomDomainName;
  319.             if (DomainName == "") 
  320.             {
  321.                 if (confirm("<%= L_CANNOT_REMV_DEFAULT_TEXT %>")) 
  322.                 {
  323.                     self.location = "smdomhd.asp?svr=<% = svr %>&ServiceInstance=<% = ServerInstance %>&a=remove&removeIndex=" + index;
  324.                 }
  325.             }
  326.             else 
  327.             {
  328.                 if (confirm("<%= L_CONFIRM_REMV_DOMAIN_TEXT %>")) 
  329.                 {
  330.                     self.location = "smdomhd.asp?svr=<% = svr %>&ServiceInstance=<% = ServerInstance %>&a=remove&removeIndex=" + index;
  331.                 }
  332.             }
  333.         }
  334.     }
  335.  
  336.  
  337. <% REM Javascript function editItem opens pop-up with specific parameters %>
  338. <% REM DirHome variable (true/false) specifies whether a Domain already exists %>
  339.     
  340.     function editItem() 
  341.     {
  342.         if(uForm.itemList.length > 0)
  343.         {
  344.             index = uForm.selectedItem;
  345.             DomainName = uForm.itemList[index].DomDomainName;
  346.              if(index == 0)
  347.             {
  348.                 winstr = "width=420,height=360,directories=no,status=no,scrollbars=auto,resize=no";
  349.             }
  350.             else 
  351.             {
  352.                 winstr = "width=420,height=560,directories=no,status=no,scrollbars=auto,resize=no";
  353.             }    
  354.             win = window.open("smdomed.asp?svr=<% = svr %>&ServiceInstance=<% = ServerInstance %>&a=edit&DomainName=" + DomainName + "&DirHome=" + uForm.DirHome + "&index=" + (index + 1),"PropWindow",winstr);
  355.             if (win.opener == null) 
  356.             {
  357.                 win.opener = self;
  358.             }
  359.         }
  360.         
  361.     }
  362.  
  363.  
  364. <% REM Javascript function loadList loads list frame after header is completed %>
  365.  
  366.     function loadList() 
  367.     {
  368.         parent.list.location = "smdomls.asp";
  369.     }    
  370.     
  371.     function loadToolBar()
  372.     {
  373.         top.toolbar.location = "nre.asp";
  374.     }
  375.     
  376. </SCRIPT>
  377.  
  378. </HEAD>
  379.  
  380. <BODY BGCOLOR="#CCCCCC" TEXT="#000000" TOPMARGIN=10 OnLoad="loadToolBar();">
  381.  
  382. <TABLE BORDER=0 WIDTH=600 CELLPADDING=2>
  383.     <TR>
  384.         <TD COLSPAN=2>
  385.             <IMG SRC="images/gnicttl.gif" ALIGN="textmiddle" HEIGHT=10 WIDTH=10> <FONT SIZE=2 FACE="Arial"><B><%= L_DOMAINSON_TEXT %>  </B></FONT><FONT SIZE=3 FACE="Times New Roman"><I><% = svr %></I><BR> </FONT>
  386.         </TD>
  387.     </TR>
  388.     <TR>
  389.         <TD WIDTH=150><FONT SIZE=2 FACE="Arial"><B><%= L_DOMAINNAME_TEXT %></B></FONT></TD>
  390.         <td width=200><FONT SIZE=2 FACE="Arial"><B><%= L_TYPE_TEXT %></b></FONT></TD>
  391.     </TR>
  392. </TABLE>
  393.  
  394.  
  395. <% REM Load list frame after head frame is finished loading %>
  396.  
  397. <SCRIPT LANGUAGE="javascript">
  398.     timeList = setTimeout('loadList()',500);
  399. </SCRIPT>
  400.  
  401. </BODY>
  402. </HTML>
  403.  
  404. <% end if %>
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.