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.

339 lines
11 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' user_setpassword.asp : Set password the specified user
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 15-jan-01 Creation date
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <%
  15. '-------------------------------------------------------------------------
  16. ' Global Variables
  17. '-------------------------------------------------------------------------
  18. ' Name of this source file
  19. Const SOURCE_FILE = "User_setpassword.asp"
  20. ' Flag to toggle optional tracing output
  21. Const ENABLE_TRACING = TRUE
  22. Dim rc 'framework variables
  23. Dim page 'framework variables
  24. '-------------------------------------------------------------------------
  25. ' Global Form Variables
  26. '-------------------------------------------------------------------------
  27. Dim F_strFirstUserName 'selected item in OTS page First Name
  28. Dim F_strNewpwd 'New password
  29. Dim F_strConfirmpwd 'Confirm Password
  30. '-------------------------------------------------------------------------
  31. 'Start of localization content
  32. '-------------------------------------------------------------------------
  33. Dim L_PAGETITLE_TEXT
  34. Dim L_NEWPASSWORD_TEXT
  35. Dim L_CONFIRMPASSWORD_TEXT
  36. Dim L_PASSWORDNOTMATCH_ERRORMESSAGE
  37. Dim L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  38. Dim L_ADSI_ERRORMESSAGE
  39. Dim L_COMPUTERNAME_ERRORMESSAGE
  40. Dim L_USERDOSENOT_EXISTS
  41. Const N_PASSWORD_COMPLEXITY_ERRNO = &H800708C5
  42. Const N_USERDOSENOT_EXISTS_ERRNO = &H800708AD
  43. L_PAGETITLE_TEXT = objLocMgr.GetString("usermsg.dll","&H40300045", varReplacementStrings)
  44. L_NEWPASSWORD_TEXT = objLocMgr.GetString("usermsg.dll","&H40300046", varReplacementStrings)
  45. L_CONFIRMPASSWORD_TEXT = objLocMgr.GetString("usermsg.dll","&H40300047", varReplacementStrings)
  46. L_PASSWORD_COMPLEXITY_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300048", varReplacementStrings)
  47. L_ADSI_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300049", varReplacementStrings)
  48. L_PASSWORDNOTMATCH_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC030004A", varReplacementStrings)
  49. L_COMPUTERNAME_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC030004B", varReplacementStrings)
  50. L_USERDOSENOT_EXISTS = objLocMgr.GetString("usermsg.dll","&H4030004C", varReplacementStrings)
  51. '-----------------------------------------------------------------------------------
  52. 'END of localization content
  53. '-----------------------------------------------------------------------------------
  54. '======================================================
  55. ' Entry point
  56. '======================================================
  57. ' Create a Property Page
  58. rc = SA_CreatePage( L_PAGETITLE_TEXT, "", PT_PROPERTY, page )
  59. '
  60. ' Serve the page
  61. rc = SA_ShowPage( page )
  62. '-------------------------------------------------------------------------
  63. 'Function: OnInitPage()
  64. 'Description: Called to signal first time processing for this page.
  65. ' Use this method to do first time initialization tasks
  66. 'Input Variables: PageIn,EventArg
  67. 'Output Variables: PageIn,EventArg
  68. 'Returns: True/False
  69. 'Global Variables: None
  70. '-------------------------------------------------------------------------
  71. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  72. If ( ENABLE_TRACING ) Then
  73. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  74. End If
  75. Call OTS_GetTableSelection("", 1, F_strFirstUserName)
  76. OnInitPage = TRUE
  77. End Function
  78. '-------------------------------------------------------------------------
  79. 'Function: OnServePropertyPage()
  80. 'Description: Called when the page needs to be served.Use this
  81. ' method to serve content
  82. 'Input Variables: PageIn,EventArg
  83. 'Output Variables: PageIn,EventArg
  84. 'Returns: True/False
  85. 'Global Variables: None
  86. '-------------------------------------------------------------------------
  87. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  88. SA_TraceOut "TEMPLATE_PROPERTY", "OnServePropertyPage"
  89. ' Emit Functions required by Web Framework
  90. Call ServeCommonJavaScript()%>
  91. <TABLE WIDTH=518 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  92. <TR>
  93. <TD colspan=6>
  94. <% CheckForSecureSite %>
  95. </TD>
  96. </TR>
  97. <TR>
  98. <TD>
  99. &nbsp;&nbsp
  100. </TD>
  101. </TR>
  102. <TR>
  103. <TD NOWRAP width=25%>
  104. <%= L_NEWPASSWORD_TEXT %>
  105. </TD>
  106. <TD>
  107. <input NAME="pwdPassword" TYPE="password" SIZE="20" VALUE="" maxlength=127>
  108. </TD>
  109. </TR>
  110. <TR>
  111. <TD NOWRAP width=25%>
  112. <%= L_CONFIRMPASSWORD_TEXT %>
  113. </TD>
  114. <TD>
  115. <input NAME="pwdConfirmPassword" TYPE="password" SIZE="20" VALUE="" maxlength=127>
  116. </TD>
  117. </TR>
  118. </TABLE>
  119. <input NAME="hdnUserName" TYPE="hidden" VALUE="<%=Server.HTMLEncode(F_strFirstUserName)%>">
  120. <%
  121. OnServePropertyPage = TRUE
  122. End Function
  123. '-------------------------------------------------------------------------
  124. 'Function: OnPostBackPage()
  125. 'Description: Called to signal that the page has been posted-back.
  126. 'Input Variables: PageIn,EventArg
  127. 'Output Variables: None
  128. 'Returns: True/False
  129. 'Global Variables: None
  130. '-------------------------------------------------------------------------
  131. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  132. OnPostBackPage = TRUE
  133. End Function
  134. '-------------------------------------------------------------------------
  135. 'Function: OnSubmitPage()
  136. 'Description: Called when the page has been submitted for processing.
  137. ' Use this method to process the submit request.
  138. 'Input Variables: PageIn,EventArg
  139. 'Output Variables: None
  140. 'Returns: True/False
  141. 'Global Variables: F_(*)
  142. '-------------------------------------------------------------------------
  143. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  144. SA_TraceOut "TEMPLATE_PROPERTY", "OnSubmitPage"
  145. F_strNewpwd = Request.Form("pwdPassword")
  146. F_strConfirmpwd = Request.Form("pwdConfirmPassword")
  147. F_strFirstUserName = Request.Form("hdnUserName")
  148. OnSubmitPage= SetUpdatePassword()
  149. End Function
  150. '-------------------------------------------------------------------------
  151. 'Function: OnClosePage()
  152. 'Description: Called when the page is about closed.Use this method
  153. ' to perform clean-up processing
  154. 'Input Variables: PageIn,EventArg
  155. 'Output Variables: None
  156. 'Returns: True/False
  157. 'Global Variables: None
  158. '-------------------------------------------------------------------------
  159. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  160. SA_TraceOut "TEMPLATE_PROPERTY", "OnClosePage"
  161. OnClosePage = TRUE
  162. End Function
  163. '-------------------------------------------------------------------------
  164. 'Function name: SetUpdatePassword
  165. 'Description: Updating the UserPassword
  166. 'Input Variables: None
  167. 'Output Variables: None
  168. 'Returns: True/False
  169. 'Global Variables:
  170. ' In:F_strFirstUserName 'User Name
  171. ' In:F_strNewpwd 'New Password
  172. ' In:L_ADSI_ERRORMESSAGE
  173. ' In:L_PASSWORDCOMPLEXITY_ERRORMESSAGE
  174. '
  175. ' If ADSI Error, calls SetErrMsg with the error string
  176. ' L_ADSI_ERRORMESSAGE.
  177. ' If Password Complexity error, calls SetErrMsg with the error string
  178. ' L_PASSWORDCOMPLEXITY_ERRORMESSAGE.
  179. ' True : If Implemented properly
  180. ' False : If Not Implemented
  181. '--------------------------------------------------------------------------
  182. Function SetUpdatePassword
  183. Err.Clear
  184. on error resume next
  185. Dim objUser
  186. Dim strADSIPath
  187. Dim strServerName
  188. 'Gets the ComputerName from the system
  189. strServerName = GetComputerName()
  190. 'sets the path to the user
  191. strADSIPath = "WinNT://" & strServerName & "/" & F_strFirstUserName & ",user"
  192. 'Gets the User from the system
  193. Set objUser = GetObject(strADSIPath)
  194. 'Response.End
  195. If Err.Number = N_USERDOSENOT_EXISTS_ERRNO Then
  196. Call SA_ServeFailurePage(L_USERDOSENOT_EXISTS )
  197. End if
  198. 'ADSI error
  199. If Err.Number <> 0 Then
  200. SetErrMsg L_ADSI_ERRORMESSAGE
  201. SetUpdatePassword = FALSE
  202. Exit Function
  203. End If
  204. objUser.setPassword(F_strNewpwd)
  205. objUser.SetInfo()
  206. 'Complexity requirements
  207. If Err.Number = N_PASSWORD_COMPLEXITY_ERRNO Then
  208. SetErrMsg L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  209. SetUpdatePassword = FALSE
  210. Exit Function
  211. End If
  212. 'If the creation fails any other reason
  213. If Err.Number <> 0 Then
  214. SetErrMsg L_ADSI_ERRORMESSAGE
  215. SetUpdatePassword = FALSE
  216. Exit Function
  217. End If
  218. Session("Item1") = F_strFirstUserName
  219. SetUpdatePassword =True
  220. Set objUser=Nothing
  221. End Function
  222. '-------------------------------------------------------------------------
  223. 'Function: ServeCommonJavaScript
  224. 'Description: Serves in initialiging the values,setting the form
  225. ' data and validating the form values
  226. 'Input Variables: None
  227. 'Output Variables: None
  228. 'Returns: None
  229. 'Global Variables: L_PASSWORDNOTMATCH_ERRORMESSAGE
  230. '-------------------------------------------------------------------------
  231. Function ServeCommonJavaScript()
  232. %>
  233. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  234. </script>
  235. <script language="JavaScript">
  236. // Init Function
  237. function Init()
  238. {
  239. document.frmTask.pwdPassword.focus();
  240. document.frmTask.pwdPassword.select();
  241. document.frmTask.action = location.href
  242. EnableCancel();
  243. SetPageChanged(false);
  244. }
  245. // ValidatePage Function
  246. // Returns: True if the page is OK, false if error(s) exist.
  247. function ValidatePage()
  248. {
  249. //alert("ValidatePage()");
  250. if (document.frmTask.pwdPassword.value != document.frmTask.pwdConfirmPassword.value)
  251. {
  252. SA_DisplayErr("<%= Server.HTMLEncode(L_PASSWORDNOTMATCH_ERRORMESSAGE) %>");
  253. document.frmTask.pwdConfirmPassword.focus();
  254. document.frmTask.pwdConfirmPassword.select();
  255. return false;
  256. }
  257. return true;
  258. }
  259. // SetData Function
  260. // This function must be included or a javascript runtime error will occur.
  261. function SetData()
  262. {
  263. //alert("SetData()");
  264. }
  265. // OnTextInputChanged
  266. // ------------------
  267. // Sample function that is invoked whenever a text input field is modified on the page.
  268. // See the onChange attribute in the HTML INPUT tags that follow.
  269. //
  270. function OnTextInputChanged(objText)
  271. {
  272. SetPageChanged(true);
  273. }
  274. // OnRadioOptionChanged
  275. // ------------------
  276. // Sample function that is invoked whenever a radio input field is modified on the page.
  277. // See the onChange attribute in the HTML INPUT tags that follow.
  278. //
  279. function OnRadioOptionChanged(objRadio)
  280. {
  281. SetPageChanged(true);
  282. }
  283. </script>
  284. <%
  285. End Function
  286. %>