Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

295 lines
8.7 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' POP3 Mail Add-in - Mailboxes - Delete
  6. ' Copyright (C) Microsoft Corporation. All rights reserved.
  7. '-------------------------------------------------------------------------
  8. %>
  9. <!-- #include virtual="/admin/inc_framework.asp" -->
  10. <!-- #include virtual="/admin/ots_main.asp" -->
  11. <!-- #include file="p3cminc.asp" -->
  12. <%
  13. '-------------------------------------------------------------------------
  14. ' Global Constants
  15. '-------------------------------------------------------------------------
  16. Dim SOURCE_FILE
  17. SOURCE_FILE = SA_GetScriptFileName()
  18. Const FLD_NAME = "fldName"
  19. Const FLD_DELETEUSER = "fldDeleteUser"
  20. '-------------------------------------------------------------------------
  21. ' Global Variables
  22. '-------------------------------------------------------------------------
  23. Dim g_page
  24. Dim g_rgFailures
  25. Dim g_nFailures
  26. Dim g_strDomainName
  27. g_strDomainName = GetDomainName()
  28. '----------------------------------------------------------------------
  29. ' Global Localized Strings
  30. '----------------------------------------------------------------------
  31. Dim l_strPageTitle
  32. If (Request.Form(FLD_NAME).Count > 0) Then
  33. ' Set the title to the error title, even though we don't know
  34. ' whether an error occurred. By the time we know an error occured,
  35. ' it will be too late to update the title, and if no error occurs,
  36. ' the user will be redirected back to the OTS.
  37. l_strPageTitle = GetLocString(RES_DLL_NAME, _
  38. POP3_PAGETITLE_MAILBOXES_DELETEERROR, _
  39. "")
  40. Else
  41. l_strPageTitle = GetLocString(RES_DLL_NAME, _
  42. POP3_PAGETITLE_MAILBOXES_DELETE, _
  43. "")
  44. End If
  45. Dim l_strConfirmPrompt
  46. l_strConfirmPrompt = GetLocString(RES_DLL_NAME, _
  47. POP3_PROMPT_MAILBOXES_DELETE, _
  48. "")
  49. Dim l_strErrorPrompt
  50. l_strErrorPrompt = GetLocString(RES_DLL_NAME, _
  51. POP3_PROMPT_MAILBOXES_DELETEERROR, _
  52. "")
  53. Dim l_strRetryPrompt
  54. l_strRetryPrompt = GetLocString(RES_DLL_NAME, _
  55. POP3_PROMPT_MAILBOXES_DELETERETRY, _
  56. "")
  57. ' POP3_CAPTION_MAILBOXES_DEL_DELETE, _
  58. Dim l_strCaptionDeleteUser
  59. l_strCaptionDeleteUser = GetLocString(RES_DLL_NAME, _
  60. POP3_CAPTION_MAILBOXES_DELETEUSER, _
  61. "")
  62. '**********************************************************************
  63. '* E N T R Y P O I N T
  64. '**********************************************************************
  65. Call SA_CreatePage(l_strPageTitle, "", PT_PROPERTY, g_page)
  66. Call SA_ShowPage (g_page)
  67. '**********************************************************************
  68. '* H E L P E R S U B R O U T I N E S
  69. '**********************************************************************
  70. '---------------------------------------------------------------------
  71. ' OutputNameList
  72. '---------------------------------------------------------------------
  73. Sub OutputNameList(rgMailboxesTable, nRows)
  74. '
  75. ' Sort the names.
  76. '
  77. Call SAQuickSort(rgMailboxesTable, 1, nRows, 1, 0)
  78. '
  79. ' Output the names in a bulleted list.
  80. '
  81. Response.Write("<UL>" & vbCrLf)
  82. Dim strAddress
  83. Dim iRow
  84. For iRow = 1 to nRows
  85. strAddress = rgMailboxesTable(iRow, 0) & "@" & g_strDomainName
  86. %>
  87. <LI><%=Server.HTMLEncode(strAddress)%></LI>
  88. <INPUT TYPE="hidden" NAME="<%=FLD_NAME%>"
  89. VALUE="<%=Server.HTMLEncode(rgMailboxesTable(iRow, 0))%>">
  90. <%
  91. Next
  92. %>
  93. </UL>
  94. <%
  95. End Sub
  96. '---------------------------------------------------------------------
  97. ' ServeCommonJavaScript
  98. '---------------------------------------------------------------------
  99. Function ServeCommonJavaScript()
  100. %>
  101. <script language="JavaScript" src="../inc_global.js">
  102. </script>
  103. <script language="JavaScript">
  104. function Init(){}
  105. function ValidatePage(){return true;}
  106. function SetData(){}
  107. </script>
  108. <%
  109. End Function
  110. '**********************************************************************
  111. '* E V E N T H A N D L E R S
  112. '**********************************************************************
  113. '---------------------------------------------------------------------
  114. ' OnInitPage
  115. '---------------------------------------------------------------------
  116. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  117. OnInitPage = true
  118. g_nFailures = 0
  119. Session("bDeleteUser") = ""
  120. End Function
  121. '---------------------------------------------------------------------
  122. ' OnServePropertyPage
  123. '---------------------------------------------------------------------
  124. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  125. On Error Resume Next
  126. Session(SESSION_POP3DOMAINNAME) = g_strDomainName
  127. '
  128. ' Emit Javascript functions required by Web Framework
  129. Call ServeCommonJavaScript()
  130. If (g_nFailures > 0) Then
  131. '
  132. ' Output the error prompt and sorted list of failed templates.
  133. '
  134. Response.Write(l_strErrorPrompt & "<BR>" & vbCrLf)
  135. Call OutputNameList(g_rgFailures, g_nFailures)
  136. Response.Write("<BR>" & l_strRetryPrompt & vbCrLf)
  137. OnServePropertyPage = true
  138. If (Err.number <> 0) Then
  139. Call SA_SetErrMsg( HandleUnexpectedError() )
  140. End If
  141. Exit Function
  142. End If
  143. Dim nRows
  144. nRows = OTS_GetTableSelectionCount("")
  145. '
  146. ' Get the list of selected devices.
  147. '
  148. Dim rgMailboxesTable
  149. ReDim rgMailboxesTable(nRows, 0)
  150. Dim strUserName
  151. Dim iRow
  152. For iRow = 1 to nRows
  153. If (OTS_GetTableSelection("", iRow, strUserName)) Then
  154. rgMailboxesTable(iRow, 0) = strUserName
  155. Else
  156. Call SA_SetErrMsg( HandleUnexpectedError() )
  157. Call SA_TraceErrorOut(SOURCE_FILE, _
  158. "Failed to get OTS selection.")
  159. End If
  160. Next
  161. '
  162. ' Output the confirmation prompt and sorted list of names.
  163. '
  164. Response.Write(l_strConfirmPrompt & "<BR>" & vbCrLf)
  165. Call OutputNameList(rgMailboxesTable, nRows)
  166. '
  167. ' If we are not using the MD5 Hash, then lets allow them to delete the user too.
  168. Dim oConfig
  169. Set oConfig = Server.CreateObject("P3Admin.P3Config")
  170. If ( oConfig.Authentication.CurrentAuthMethod <> AUTH_FILE ) Then
  171. %>
  172. <INPUT TYPE="CHECKBOX" NAME="<%=FLD_DELETEUSER%>" ID="<%=FLD_DELETEUSER%>">
  173. <LABEL FOR="<%=FLD_DELETEUSER%>"><%=Server.HTMLEncode(l_strCaptionDeleteUser)%></LABEL>
  174. <%
  175. End If
  176. If (Err.number <> 0) Then
  177. Call SA_SetErrMsg( HandleUnexpectedError() )
  178. End If
  179. OnServePropertyPage = true
  180. End Function
  181. '---------------------------------------------------------------------
  182. ' OnPostBackPage
  183. '---------------------------------------------------------------------
  184. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  185. OnPostBackPage = true
  186. End Function
  187. '---------------------------------------------------------------------
  188. ' OnSubmitPage
  189. '---------------------------------------------------------------------
  190. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  191. On Error Resume Next
  192. OnSubmitPage = false
  193. Dim oConfig
  194. Set oConfig = Server.CreateObject("P3Admin.P3Config")
  195. Dim nRows
  196. nRows = Request.Form(FLD_NAME).Count
  197. ' Create an array to hold the names of any templates that could
  198. ' not be deleted.
  199. ReDim g_rgFailures(nRows, 0)
  200. g_nFailures = 0
  201. ' Keep state for the Delete associated user checkbox.
  202. If ( Session("bDeleteUser") = "" ) Then
  203. If ( StrComp(Request.Form(FLD_DELETEUSER), "on", vbTextCompare) = 0 ) Then
  204. Session("bDeleteUser") = true
  205. Else
  206. Session("bDeleteUser") = false
  207. End If
  208. End If
  209. '
  210. ' Iterate over the selected templates and delete them.
  211. '
  212. Dim strUserName
  213. Dim iRow
  214. For iRow = 1 to nRows
  215. strUserName = Request.Form(FLD_NAME).Item(iRow)
  216. ' Here we actually do the delete.
  217. If ( CBool(Session("bDeleteUser")) ) Then
  218. oConfig.Domains.Item(g_strDomainName).Users.RemoveEx(strUserName)
  219. Else
  220. oConfig.Domains.Item(g_strDomainName).Users.Remove(strUserName)
  221. End If
  222. If (Err.number <> 0) Then
  223. g_nFailures = g_nFailures + 1
  224. g_rgFailures(g_nFailures, 0) = strUserName
  225. If (Err.number <> 0) Then
  226. Call SA_SetErrMsg( HandleUnexpectedError() )
  227. Err.Clear()
  228. ' Don't return -- keep trying to delete the rest of the objects.
  229. End If
  230. End If
  231. Next
  232. If (g_nFailures > 0) Then
  233. OnSubmitPage = false
  234. Exit Function
  235. End If
  236. OnSubmitPage = true
  237. End Function
  238. '---------------------------------------------------------------------
  239. ' OnClosePage
  240. '---------------------------------------------------------------------
  241. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  242. OnClosePage = true
  243. End Function
  244. %>