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.

278 lines
8.9 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' POP3 Mail Add-in - New Mailbox
  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_PASSWORD = "fldPassword"
  20. Const FLD_CONFIRM = "fldPasswordConfirm"
  21. Const FLD_CREATEUSER = "fldCreateUser"
  22. '-------------------------------------------------------------------------
  23. ' Global Variables
  24. '-------------------------------------------------------------------------
  25. Dim g_page
  26. Dim g_strName
  27. Dim g_bCreateUser
  28. Dim g_strDomainName
  29. g_strDomainName = GetDomainName()
  30. '----------------------------------------------------------------------
  31. ' Global Localized Strings
  32. '----------------------------------------------------------------------
  33. Dim l_strPageTitle
  34. l_strPageTitle = GetLocString(RES_DLL_NAME, _
  35. POP3_PAGETITLE_MAILBOXES_NEW, _
  36. Array(g_strDomainName))
  37. Dim l_strCaptionName
  38. l_strCaptionName = GetLocString(RES_DLL_NAME, _
  39. POP3_CAPTION_MAILBOXES_NEW_NAME, _
  40. Array(g_strDomainName))
  41. Dim l_strCaptionPassword
  42. l_strCaptionPassword = GetLocString(RES_DLL_NAME, _
  43. POP3_CAPTION_MAILBOXES_NEW_PASSWORD, _
  44. Array(g_strDomainName))
  45. Dim l_strCaptionConfirm
  46. l_strCaptionConfirm = GetLocString(RES_DLL_NAME, _
  47. POP3_CAPTION_MAILBOXES_NEW_CONFIRMPASSWORD, _
  48. Array(g_strDomainName))
  49. Dim l_strCaptionCreateUser
  50. l_strCaptionCreateUser = GetLocString(RES_DLL_NAME, _
  51. POP3_CAPTION_MAILBOXES_NEW_CREATEUSERS, _
  52. Array(g_strDomainName))
  53. '**********************************************************************
  54. '* E N T R Y P O I N T
  55. '**********************************************************************
  56. Call SA_CreatePage(l_strPageTitle, "", PT_PROPERTY, g_page)
  57. Call SA_ShowPage (g_page)
  58. '**********************************************************************
  59. '* H E L P E R S U B R O U T I N E S
  60. '**********************************************************************
  61. '---------------------------------------------------------------------
  62. ' ServeCommonJavaScript
  63. '---------------------------------------------------------------------
  64. Function ServeCommonJavaScript()
  65. %>
  66. <script language="JavaScript" src="../inc_global.js">
  67. </script>
  68. <script language="JavaScript">
  69. function Init()
  70. {
  71. frmTask.<%= FLD_NAME %>.focus() ;
  72. }
  73. function ValidatePage()
  74. {
  75. return true;
  76. }
  77. function SetData()
  78. {
  79. }
  80. function OnCreateClick()
  81. {
  82. if ( frmTask.<%=FLD_CREATEUSER%>.checked )
  83. {
  84. frmTask.<%=FLD_PASSWORD%>.disabled = false ;
  85. frmTask.<%=FLD_CONFIRM%>.disabled = false ;
  86. frmTask.<%=FLD_PASSWORD%>.style.background = "" ;
  87. frmTask.<%=FLD_CONFIRM%>.style.background = "" ;
  88. }
  89. else
  90. {
  91. frmTask.<%=FLD_PASSWORD%>.disabled = true ;
  92. frmTask.<%=FLD_CONFIRM%>.disabled = true ;
  93. frmTask.<%=FLD_PASSWORD%>.style.background = "lightgrey" ;
  94. frmTask.<%=FLD_CONFIRM%>.style.background = "lightgrey" ;
  95. }
  96. }
  97. </script>
  98. <%
  99. End Function
  100. '**********************************************************************
  101. '* E V E N T H A N D L E R S
  102. '**********************************************************************
  103. '---------------------------------------------------------------------
  104. ' OnInitPage
  105. '---------------------------------------------------------------------
  106. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  107. g_strName = ""
  108. g_bCreateUser = true
  109. OnInitPage = TRUE
  110. End Function
  111. '---------------------------------------------------------------------
  112. ' OnServePropertyPage
  113. '---------------------------------------------------------------------
  114. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  115. On Error Resume Next
  116. Session(SESSION_POP3DOMAINNAME) = g_strDomainName
  117. OnServePropertyPage = TRUE
  118. '
  119. ' Emit Javascript functions required by Web Framework
  120. Call ServeCommonJavaScript()
  121. Dim oConfig
  122. Dim strAuthMethod
  123. Dim bIsHash
  124. Dim iNameLen
  125. Set oConfig = Server.CreateObject("P3Admin.P3Config")
  126. strAuthMethod = oConfig.Authentication.Item(oConfig.Authentication.CurrentAuthMethod).ID
  127. If ( strAuthMethod = AUTH_FILE ) Then
  128. bIsHash = true
  129. g_bCreateUser = true
  130. End If
  131. iNameLen = 255
  132. If ( strAuthMethod = AUTH_SAM ) Then
  133. iNameLen = 20
  134. End If
  135. %>
  136. <TABLE CLASS="TasksBody" CELLPADDING=0 CELLSPACING=0>
  137. <TR>
  138. <TD CLASS="TasksBody">
  139. <%=Server.HTMLEncode(l_strCaptionName)%>
  140. </TD>
  141. <TD CLASS="TasksBody">
  142. <INPUT TYPE="text"
  143. CLASS="FormField"
  144. NAME="<%=FLD_NAME%>"
  145. ID="<%=FLD_NAME%>"
  146. VALUE="<%=Server.HTMLEncode(g_strName)%>"
  147. STYLE="width: 350px;"
  148. MAXLENGTH="<%=CStr(iNameLen)%>">
  149. </TD>
  150. </TR>
  151. <TR>
  152. <TD CLASS="TasksBody">
  153. <%=Server.HTMLEncode(l_strCaptionPassword)%>
  154. </TD>
  155. <TD CLASS="TasksBody">
  156. <INPUT TYPE="password"
  157. CLASS="FormField"
  158. NAME="<%=FLD_PASSWORD%>"
  159. ID="<%=FLD_PASSWORD%>"
  160. <% If NOT g_bCreateUser Then %> DISABLED="TRUE" STYLE="width: 350px;background:lightgrey;" <% Else %> STYLE="width: 350px;" <% End If%>
  161. MAXLENGTH="255">
  162. </TD>
  163. </TR>
  164. <TR>
  165. <TD CLASS="TasksBody">
  166. <%=Server.HTMLEncode(l_strCaptionConfirm)%>
  167. </TD>
  168. <TD CLASS="TasksBody">
  169. <INPUT TYPE="password"
  170. CLASS="FormField"
  171. NAME="<%=FLD_CONFIRM%>"
  172. ID="<%=FLD_CONFIRM%>"
  173. <% If NOT g_bCreateUser Then %> DISABLED="TRUE" STYLE="width: 350px;background:lightgrey;" <% Else %> STYLE="width: 350px;" <% End If%>
  174. MAXLENGTH="255">
  175. </TD>
  176. </TR>
  177. </TABLE>
  178. <BR>
  179. <INPUT TYPE="CHECKBOX" NAME="<%=FLD_CREATEUSER%>" ID="<%=FLD_CREATEUSER%>" <%If g_bCreateUser Then %> CHECKED <% End If%> onclick='return OnCreateClick();' <%If bIsHash Then %> style="display:none;" <% End If %>>
  180. <LABEL FOR="<%=FLD_CREATEUSER%>" <%If bIsHash Then %> style="display:none;" <% End If %>><%=Server.HTMLEncode(l_strCaptionCreateUser)%></LABEL>
  181. <%
  182. If (Err.number <> 0) Then
  183. Call SA_SetErrMsg( HandleUnexpectedError() )
  184. End If
  185. End Function
  186. '---------------------------------------------------------------------
  187. ' OnPostBackPage
  188. '---------------------------------------------------------------------
  189. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  190. On Error Resume Next
  191. g_strName = Request.Form(FLD_NAME).Item(1)
  192. If ( StrComp(Request.Form(FLD_CREATEUSER), "on", vbTextCompare) = 0 ) Then
  193. g_bCreateUser = true
  194. Else
  195. g_bCreateUser = false
  196. End If
  197. OnPostBackPage = TRUE
  198. End Function
  199. '---------------------------------------------------------------------
  200. ' OnSubmitPage
  201. '---------------------------------------------------------------------
  202. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  203. On Error Resume Next
  204. Dim oConfig, oDomains, oDomain, oUsers, strAuthMethod
  205. Set oConfig = Server.CreateObject("P3Admin.P3Config")
  206. Set oUsers = oConfig.Domains.Item (g_strDomainName).Users
  207. '
  208. ' Verify that the passwords match.
  209. '
  210. strAuthMethod = oConfig.Authentication.Item(oConfig.Authentication.CurrentAuthMethod).ID
  211. If ( g_bCreateUser Or strAuthMethod = AUTH_FILE ) Then
  212. Dim strPassword
  213. strPassword = Request.Form(FLD_PASSWORD).Item(1)
  214. If (strPassword <> Request.Form(FLD_CONFIRM).Item(1)) Then
  215. Call SA_SetErrMsg(GetLocString(RES_DLL_NAME, _
  216. POP3_E_PASSWORDMISMATCH, _
  217. Array(CStr(Hex(Err.number)))))
  218. OnSubmitPage = false
  219. Exit Function
  220. End If
  221. End If
  222. '
  223. ' Create the mailbox.
  224. '
  225. If ( g_bCreateUser Or strAuthMethod = AUTH_FILE ) Then
  226. Call oUsers.AddEx ( g_strName, strPassword )
  227. Else
  228. Call oUsers.Add ( g_strName )
  229. End If
  230. If (Err.number <> 0) Then
  231. Call SA_SetErrMsg( HandleUnexpectedError() )
  232. OnSubmitPage = false
  233. Exit Function
  234. End If
  235. OnSubmitPage = true
  236. End Function
  237. '---------------------------------------------------------------------
  238. ' OnClosePage
  239. '---------------------------------------------------------------------
  240. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  241. OnClosePage = TRUE
  242. End Function
  243. %>