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.

653 lines
23 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' user_prop.asp : get's and set's the user properties.
  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. <!-- #include file="inc_usersngroups.asp" -->
  15. <%
  16. '-------------------------------------------------------------------------
  17. ' Global Constants and Variables
  18. '-------------------------------------------------------------------------
  19. ' Name of this source file
  20. Const SOURCE_FILE = "User_new.asp"
  21. ' Flag to toggle optional tracing output
  22. Const ENABLE_TRACING = TRUE
  23. Dim rc 'framework variables
  24. Dim page 'framework variables
  25. Dim idTabGeneral 'framework variables
  26. '-------------------------------------------------------------------------
  27. ' Global Form Variables
  28. '-------------------------------------------------------------------------
  29. Dim F_strUsername 'User Name
  30. Dim F_strFullname 'Full Name
  31. Dim F_strDescription 'Description
  32. Dim F_strPassword 'Password
  33. Dim F_strConfirmpassword 'Confirm Password
  34. Dim F_strIsChecked 'Used to store checked/unchecked
  35. Dim F_blnIsChecked 'var for getting user info
  36. Dim F_strHDIsChecked 'var for store state of HomeDirectory's checkbox
  37. Dim F_strHomeDirectory 'Home Directory
  38. Dim F_strDefaultHomeDir 'Default path by OEM
  39. 'Flag for setting disable property
  40. CONST UF_ACCOUNTDISABLE = &H0002
  41. Const N_NONUNIQUEUSERNAME_ERRNO = &H800708B0
  42. Const N_USERNAMEINVALID_ERRNO = &H8007089A
  43. Const N_PASSWORD_COMPLEXITY_ERRNO = &H800708C5
  44. Const N_GROUP_EXISTS_ERRNO = &H80070563
  45. '------------------------------------------------------------------------
  46. 'Start of localization content
  47. '------------------------------------------------------------------------
  48. Dim L_PAGETITLE_TEXT
  49. Dim L_USERNAME_TEXT
  50. Dim L_FULLNAME_TEXT
  51. Dim L_DESCRIPTION_TEXT
  52. Dim L_PASSWORD_TEXT
  53. Dim L_CONFIRMPASSWORD_TEXT
  54. Dim L_USERDISABLED_TEXT
  55. Dim L_NOINPUTDATA_TEXT
  56. Dim L_TABPROPSHEET_TEXT
  57. Dim L_TABLEHEADING_TEXT
  58. Dim L_GENERAL_TEXT
  59. Dim L_HOMEDIRECTORY_TEXT
  60. Dim L_HOMEPATH_TEXT
  61. Dim L_ENTERNAME_ERRORMESSAGE
  62. Dim L_PASSWORDNOTMATCH_ERRORMESSAGE
  63. Dim L_ADSI_ERRORMESSAGE
  64. Dim L_INVALIDCHARACTER_ERRORMESSAGE
  65. Dim L_NONUNIQUEUSERNAME_ERRORMESSAGE
  66. Dim L_COMPUTERNAME_ERRORMESSAGE
  67. Dim L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  68. Dim L_GROUP_EXISTS_ERRORMESSAGE
  69. Dim L_HOMEDIRECTORY_ERRORMESSAGE
  70. Dim L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  71. Dim L_CREATEHOMEDIRECTORY_EXISTMESSAGE
  72. L_NOINPUTDATA_TEXT = objLocMgr.GetString("usermsg.dll","&H40300019", varReplacementStrings)
  73. L_TABPROPSHEET_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001A", varReplacementStrings)
  74. L_TABLEHEADING_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001B", varReplacementStrings)
  75. L_GENERAL_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001C", varReplacementStrings)
  76. L_PAGETITLE_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001D", varReplacementStrings)
  77. L_USERNAME_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001E", varReplacementStrings)
  78. L_FULLNAME_TEXT = objLocMgr.GetString("usermsg.dll","&H4030001F", varReplacementStrings)
  79. L_DESCRIPTION_TEXT = objLocMgr.GetString("usermsg.dll","&H40300020", varReplacementStrings)
  80. L_PASSWORD_TEXT = objLocMgr.GetString("usermsg.dll","&H40300021", varReplacementStrings)
  81. L_CONFIRMPASSWORD_TEXT = objLocMgr.GetString("usermsg.dll","&H40300022", varReplacementStrings)
  82. L_USERDISABLED_TEXT = objLocMgr.GetString("usermsg.dll","&H40300023", varReplacementStrings)
  83. L_HOMEDIRECTORY_TEXT = objLocMgr.GetString("usermsg.dll","&H40300052", varReplacementStrings)
  84. L_HOMEPATH_TEXT = objLocMgr.GetString("usermsg.dll","&H40300054", varReplacementStrings)
  85. L_COMPUTERNAME_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300024", varReplacementStrings)
  86. L_ENTERNAME_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300025", varReplacementStrings)
  87. L_PASSWORDNOTMATCH_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300026", varReplacementStrings)
  88. L_NONUNIQUEUSERNAME_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300027", varReplacementStrings)
  89. L_INVALIDCHARACTER_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300028", varReplacementStrings)
  90. L_ADSI_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300029", varReplacementStrings)
  91. L_PASSWORD_COMPLEXITY_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC030002A", varReplacementStrings)
  92. L_GROUP_EXISTS_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC030002B", varReplacementStrings)
  93. L_HOMEDIRECTORY_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300053", varReplacementStrings)
  94. L_CREATEHOMEDIRECTORY_ERRORMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300057", varReplacementStrings)
  95. L_CREATEHOMEDIRECTORY_EXISTMESSAGE = objLocMgr.GetString("usermsg.dll","&HC0300059", varReplacementStrings)
  96. '------------------------------------------------------------------------
  97. 'END of localization content
  98. '------------------------------------------------------------------------
  99. ' Create a Tabbed Property Page
  100. rc = SA_CreatePage(L_PAGETITLE_TEXT, "", PT_TABBED, page )
  101. ' Add one tab
  102. rc = SA_AddTabPage( page,L_PAGETITLE_TEXT, idTabGeneral)
  103. ' Show the page
  104. rc = SA_ShowPage( page )
  105. '-------------------------------------------------------------------------
  106. 'Function: OnInitPage()
  107. 'Description: Called to signal first time processing for this page.
  108. ' Use this method to do first time initialization tasks
  109. 'Input Variables: PageIn,EventArg
  110. 'Output Variables: PageIn,EventArg
  111. 'Returns: True/False
  112. 'Global Variables: None
  113. '-------------------------------------------------------------------------
  114. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  115. If ( ENABLE_TRACING ) Then
  116. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  117. End If
  118. OnInitPage = FALSE
  119. Dim objReg
  120. Dim strDefaultHomeDir
  121. Set objReg = RegConnection()
  122. strDefaultHomeDir = GetRegKeyValue( objReg,_
  123. CONST_USERGROUP_KEYNAME,_
  124. CONST_USERDIR_VALUENAME,_
  125. CONST_STRING )
  126. If ( Len(strDefaultHomeDir) <= 0 ) Then
  127. F_strDefaultHomeDir = CONST_DEFAULTHOMEDIR
  128. Else
  129. F_strDefaultHomeDir = strDefaultHomeDir
  130. End If
  131. F_strHomeDirectory = ""
  132. F_strHDIsChecked = "unchecked"
  133. Set objReg = nothing
  134. OnInitPage = TRUE
  135. End Function
  136. '-------------------------------------------------------------------------
  137. 'Function: OnPostBackPage()
  138. 'Description: Called to signal that the page has been posted-back.
  139. 'Input Variables: PageIn,EventArg
  140. 'Output Variables: None
  141. 'Returns: True/False
  142. 'Global Variables: None
  143. '-------------------------------------------------------------------------
  144. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  145. If ( ENABLE_TRACING ) Then
  146. Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  147. End If
  148. 'Only one table in the page,so nothing need to do here.
  149. OnPostBackPage = TRUE
  150. End Function
  151. '-------------------------------------------------------------------------
  152. 'Function: OnServeTabbedPropertyPage()
  153. 'Description: Called when the page needs to be served.Use this
  154. ' method to serve content
  155. 'Input Variables: PageIn,EventArg,iTab,bIsVisible
  156. 'Output Variables: PageIn,EventArg
  157. 'Returns: True/False
  158. 'Global Variables: idTabGeneral
  159. ' TRUE to indicate not problems occured. FALSE to indicate errors.
  160. ' Returning FALSE will cause the page to be abandoned.
  161. '-------------------------------------------------------------------------
  162. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  163. ByVal iTab, _
  164. ByVal bIsVisible, ByRef EventArg)
  165. If ( ENABLE_TRACING ) Then
  166. Call SA_TraceOut(SOURCE_FILE, "OnServeTabbedPropertyPage")
  167. End If
  168. ' Emit Web Framework required functions
  169. Call ServeCommonJavaScript()
  170. ' Emit content for the requested tab
  171. Call ServeTab1(PageIn, bIsVisible)
  172. OnServeTabbedPropertyPage = TRUE
  173. End Function
  174. '-------------------------------------------------------------------------
  175. 'Function: OnSubmitPage()
  176. 'Description: Called when the page has been submitted for processing.
  177. ' Use this method to process the submit request.
  178. 'Input Variables: PageIn,EventArg
  179. 'Output Variables: PageIn,EventArg
  180. 'Returns: True/False
  181. 'Global Variables: F_(*)
  182. '-------------------------------------------------------------------------
  183. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  184. If ( ENABLE_TRACING ) Then
  185. Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  186. End If
  187. F_strUsername =Trim(Request.Form("txtUserName"))
  188. F_strFullname =Trim(Request.Form("txtFullName") )
  189. F_strDescription =Trim(Request.Form("txtDescription"))
  190. F_strPassword =Trim(Request.Form("pwdPassword"))
  191. F_strConfirmpassword =Trim(Request.Form("pwdConfirmPassword"))
  192. F_blnIsChecked =Trim(Request.Form("chkUserDisabled"))
  193. F_strHDIschecked =Trim(Request.Form("chkHomePath"))
  194. F_strHomeDirectory =Trim(Request.Form("txtHomeDirectory"))
  195. F_strDefaultHomeDir =Trim(Request.Form("hdnDefaultDir"))
  196. If ( Len(F_blnIsChecked ) <= 0 ) Then
  197. F_blnIsChecked = FALSE
  198. End If
  199. If ( F_blnIsChecked ) Then
  200. F_strIsChecked = "checked"
  201. Else
  202. F_strIsChecked = ""
  203. End If
  204. OnSubmitPage = CreateUser()
  205. End Function
  206. '-------------------------------------------------------------------------
  207. 'Function: OnClosePage()
  208. 'Description: Called when the page is about closed.Use this method
  209. ' to perform clean-up processing
  210. 'Input Variables: PageIn,EventArg
  211. 'Output Variables: None
  212. 'Returns: True/False
  213. 'Global Variables: None
  214. '-------------------------------------------------------------------------
  215. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  216. If ( ENABLE_TRACING ) Then
  217. Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  218. End If
  219. OnClosePage = TRUE
  220. End Function
  221. '-------------------------------------------------------------------------
  222. 'Function name: CreateUser
  223. 'Description: Creating the NewUser
  224. 'Input Variables: None
  225. 'Output Variables: None
  226. 'Returns: (True / Flase )
  227. 'Global Variables: None
  228. ' In:F_strFullname 'Fullname
  229. ' In:F_strDescription 'Description
  230. ' In:F_strPassword 'Password
  231. ' In:F_strUsername 'Username
  232. ' In:F_blnIsChecked '
  233. ' In:L_ADSI_ERRORMESSAGE 'ADSI error message
  234. ' In:L_NONUNIQUEUSERNAME_ERRORMESSAGE 'Username allready exists error
  235. ' In:L_SPECIFIEDUSERNAMEINVALID_ERRORMESSAGE 'Invalid User error message
  236. ' In:L_PASSWORD_COMPLEXITY_ERRORMESSAGE 'Password Complexity error
  237. ' True ->If Implemented properly
  238. ' False->If Not Implemented
  239. ' If ADSI Error, calls ServeFailurePage with the error string
  240. ' L_ADSI_ERRORMESSAGE.
  241. ' If Password Complexity error, calls SetErrMsg with the error string
  242. ' L_PASSWORD_COMPLEXITY_ERRORMESSAGE.
  243. ' Username allready exists, calls SetErrMsg with the error string
  244. ' L_NONUNIQUEUSERNAME_ERRORMESSAGE.
  245. ' If ADSI Error, calls SetErrMsg with the error string
  246. ' L_ADSI_ERRORMESSAGE.
  247. ' Const:UF_ACCOUNTDISABLE for setting disable property
  248. '--------------------------------------------------------------------------
  249. Function CreateUser()
  250. Err.Clear
  251. on error resume next
  252. Dim objComputer
  253. Dim objUser
  254. Dim objFileSystem
  255. Dim flagUserFlags
  256. Dim strComputerName 'Stores the Computer Name
  257. Dim strHomeDirectory
  258. Dim bReturn
  259. CreateUser = false
  260. If (F_strHDIschecked = "checked") Then
  261. strHomeDirectory = F_strHomeDirectory
  262. Else
  263. strHomeDirectory = ""
  264. End If
  265. Set objFileSystem=createobject("scripting.FileSystemObject")
  266. If Err.number <> 0 Then
  267. SetErrMsg L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  268. Exit Function
  269. End If
  270. ' Getting the local computer name by calling the function
  271. strComputerName = GetComputerName()
  272. Set objComputer =GetObject("WinNT://" & strComputerName & ",computer")
  273. 'ADSI error message
  274. If Err.number <> 0 Then
  275. Call ServeFailurePage(L_ADSI_ERRORMESSAGE,1)
  276. CreateUser=false
  277. Exit function
  278. End if
  279. Set objUser = objComputer.Create("user" , F_strUsername )
  280. 'ADSI error message
  281. If Err.number <> 0 Then
  282. Call ServeFailurePage(L_ADSI_ERRORMESSAGE,1)
  283. CreateUser=false
  284. Exit function
  285. End if
  286. objUser.setPassword(F_strPassword)
  287. objUser.FullName = F_strFullname
  288. objUser.Description = F_strDescription
  289. If ( strHomeDirectory <> "" ) Then
  290. objUser.HomeDirectory = strHomeDirectory
  291. End If
  292. If F_blnIsChecked Then
  293. flagUserFlags = objUser.UserFlags OR UF_ACCOUNTDISABLE
  294. objUser.Put "UserFlags", flagUserFlags
  295. End If
  296. objUser.SetInfo()
  297. If Err.number <> 0 Then
  298. 'The username already exists
  299. If Err.number = N_NONUNIQUEUSERNAME_ERRNO Then
  300. SetErrMsg L_NONUNIQUEUSERNAME_ERRORMESSAGE
  301. 'Specified username is invalid
  302. Elseif Err.number = N_USERNAMEINVALID_ERRNO Then
  303. SetErrMsg L_INVALIDCHARACTER_ERRORMESSAGE
  304. 'Password Complexity Error Message
  305. Elseif Err.Number = N_PASSWORD_COMPLEXITY_ERRNO Then
  306. SetErrMsg L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  307. Elseif Err.Number = N_GROUP_EXISTS_ERRNO Then
  308. SetErrMsg L_GROUP_EXISTS_ERRORMESSAGE
  309. Else
  310. 'User could not be created
  311. SetErrMsg L_ADSI_ERRORMESSAGE
  312. End if
  313. CreateUser=false
  314. Exit Function
  315. End If
  316. If ( strHomeDirectory <> "" ) Then
  317. bReturn = CreateHomeDirectory( strHomeDirectory, objFileSystem )
  318. If( bReturn = CONST_CREATDIRECTORY_ERROR ) Then
  319. SetErrMsg L_CREATEHOMEDIRECTORY_ERRORMESSAGE
  320. Exit Function
  321. ElseIf( bReturn = CONST_CREATDIRECTORY_EXIST ) Then
  322. SetErrMsg L_CREATEHOMEDIRECTORY_EXISTMESSAGE
  323. Exit Function
  324. End If
  325. End If
  326. If ( strHomeDirectory <> "" ) Then
  327. Call SetHomeDirectoryPermission( strComputerName, F_strUsername, strHomeDirectory )
  328. End If
  329. Set objComputer = Nothing
  330. Set objUser = Nothing
  331. Set objFileSystem = Nothing
  332. CreateUser=true
  333. End Function
  334. '-------------------------------------------------------------------------
  335. 'Function: ServeTab1
  336. 'Description: Serves in getting the page for tab1
  337. 'Input Variables: PageIn,bIsVisible
  338. 'Output Variables: PageIn
  339. 'Returns: gc_ERR_SUCCESS
  340. 'Global Variables: L_(*) All
  341. '-------------------------------------------------------------------------
  342. Function ServeTab1(ByRef PageIn, ByVal bIsVisible)
  343. 'If ( bIsVisible ) Then
  344. %>
  345. <table width=518 valign=middle align=left border=0 cellspacing=0
  346. CELLPADDING=2 class="TasksBody">
  347. <TR>
  348. <TD colspan=6>
  349. <% CheckForSecureSite %>
  350. </TD>
  351. </TR>
  352. <TR>
  353. <TD>
  354. &nbsp;&nbsp
  355. </TD>
  356. </TR>
  357. <tr>
  358. <td width=25% nowrap>
  359. <%=L_USERNAME_TEXT %>
  360. </td>
  361. <td nowrap>
  362. <input TYPE="text" NAME="txtUserName" SIZE="20" MAXLENGTH="20" onfocus="this.select()" onkeyup="makeDisable(this)" onMouseOut="makeDisable(this)" value="<%=server.HTMLEncode(F_strUsername)%>">
  363. </td>
  364. </tr>
  365. <tr>
  366. <td width=25% nowrap>
  367. <%=L_FULLNAME_TEXT %>
  368. </td>
  369. <td nowrap>
  370. <input TYPE="text" NAME="txtFullName" SIZE="20" MAXLENGTH="25" onfocus="this.select()" value="<%=server.HTMLEncode(F_strFullname)%>">
  371. </td>
  372. </tr>
  373. <tr>
  374. <td width=25% nowrap>
  375. <%=L_DESCRIPTION_TEXT %>
  376. </td>
  377. <td>
  378. <input NAME="txtDescription" TYPE="text" SIZE="40" VALUE="<%=Server.HTMLEncode(F_strDescription)%>" maxlength=300>
  379. </td>
  380. </tr>
  381. <tr>
  382. <td width=25% nowrap>
  383. <% =L_PASSWORD_TEXT %>
  384. </td>
  385. <td nowrap>
  386. <input TYPE="password" NAME="pwdPassword" SIZE="20" MAXLENGTH="127" value="<%=server.HTMLEncode(F_strPassword)%>">
  387. </td>
  388. </tr>
  389. <tr>
  390. <td width=25% nowrap>
  391. <% =L_CONFIRMPASSWORD_TEXT %>
  392. </td>
  393. <td>
  394. <input TYPE="password" NAME="pwdConfirmPassword" SIZE="20" MAXLENGTH="127" value="<%=server.HTMLEncode(F_strConfirmpassword)%>">
  395. </td>
  396. </tr>
  397. <tr>
  398. <td width=25% nowrap>
  399. <% =L_HOMEDIRECTORY_TEXT %>
  400. </td>
  401. <td>
  402. <input TYPE="checkbox" value='1' <%=F_strHDIschecked%> class="FormCheckBox" NAME="chkHomePath" onclick="checkClick()">
  403. <% =L_HOMEPATH_TEXT %>
  404. &nbsp;&nbsp;
  405. <input TYPE="text" NAME="txtHomeDirectory" disabled SIZE="40" VALUE="<%=Server.HTMLEncode(F_strHomeDirectory)%>" maxlength=300>
  406. <input TYPE="hidden" NAME="hdnDefaultDir" VALUE="<%=Server.HTMLEncode(F_strDefaultHomeDir)%>" >
  407. </td>
  408. </tr>
  409. <tr>
  410. <td width=25% nowrap>
  411. </td>
  412. <td>
  413. <input TYPE="checkbox" value='1' <%=F_strIschecked%> class="FormCheckBox" NAME="chkUserDisabled">
  414. <%=L_USERDISABLED_TEXT %>
  415. </td>
  416. </tr>
  417. </TABLE>
  418. <%
  419. 'End If
  420. ServeTab1 = gc_ERR_SUCCESS
  421. End Function
  422. '-------------------------------------------------------------------------
  423. 'Function: ServeCommonJavaScript
  424. 'Description: Serves in initialiging the values,setting the form
  425. ' data and validating the form values
  426. 'Input Variables: None
  427. 'Output Variables: None
  428. 'Returns: None
  429. 'Global Variables: L_PASSWORDNOTMATCH_ERRORMESSAGE
  430. '-------------------------------------------------------------------------
  431. Function ServeCommonJavaScript()
  432. %>
  433. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  434. </script>
  435. <script language="JavaScript">
  436. // Init Function
  437. function Init()
  438. {
  439. if( document.frmTask.chkHomePath.checked == true )
  440. {
  441. document.frmTask.txtHomeDirectory.style.backgroundColor = document.frmTask.style.backgroundColor;
  442. document.frmTask.txtHomeDirectory.disabled = false;
  443. document.frmTask.chkHomePath.value = "checked";
  444. document.frmTask.txtHomeDirectory.focus();
  445. document.frmTask.txtHomeDirectory.select();
  446. }
  447. else
  448. {
  449. document.frmTask.txtUserName.focus();
  450. document.frmTask.txtUserName.select();
  451. document.frmTask.txtHomeDirectory.style.backgroundColor = 0xD3D3D3;
  452. document.frmTask.txtHomeDirectory.value = "";
  453. document.frmTask.txtHomeDirectory.disabled = true;
  454. document.frmTask.chkHomePath.value = "unchecked";
  455. }
  456. // Set Cancel button status
  457. EnableCancel();
  458. // Set OK Button status
  459. if ( document.frmTask.txtUserName )
  460. {
  461. if ( document.frmTask.txtUserName.value.length < 1 )
  462. {
  463. DisableOK();
  464. }
  465. else
  466. {
  467. EnableOK();
  468. }
  469. }
  470. // for clearing error message when serverside error occurs
  471. document.frmTask.onkeypress = ClearErr
  472. return;
  473. }
  474. // ValidatePage Function
  475. // Returns: True if the page is OK, false if error(s) exist.
  476. function ValidatePage()
  477. {
  478. var objUsername=document.frmTask.txtUserName;
  479. var strUsername=objUsername.value;
  480. //Blank Usename Validation
  481. if (Trim(strUsername)=="")
  482. {
  483. SA_DisplayErr("<%=Server.HTMLEncode(L_ENTERNAME_ERRORMESSAGE) %>");
  484. document.frmTask.onkeypress = ClearErr
  485. return false;
  486. }
  487. //Password and comfirm password validation
  488. if (document.frmTask.pwdPassword.value!=document.frmTask.pwdConfirmPassword.value)
  489. {
  490. SA_DisplayErr("<%=Server.HTMLEncode(L_PASSWORDNOTMATCH_ERRORMESSAGE) %>");
  491. document.frmTask.onkeypress = ClearErr
  492. return false;
  493. }
  494. // Checks For Invalid Key Entry
  495. if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\\\\\]/",strUsername))
  496. {
  497. SA_DisplayErr("<% =Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE) %>");
  498. document.frmTask.onkeypress = ClearErr
  499. return false;
  500. }
  501. var bIsChecked = document.frmTask.chkHomePath.checked
  502. if( bIsChecked == true )
  503. {
  504. var objHomeDirectory = document.frmTask.txtHomeDirectory;
  505. var strHomeDirectory = Trim(objHomeDirectory.value);
  506. var bStringValid = false;
  507. if( strHomeDirectory == "" )
  508. {
  509. return true;
  510. }
  511. do{
  512. if( !strHomeDirectory.match( /^[A-Za-z]:\\/ ) )
  513. break;
  514. if( strHomeDirectory.match( /\\{2,}/ ) )
  515. break;
  516. if( (strHomeDirectory.substr(2)).match( /[\/\*\?\|,;:"<>]/ ) )
  517. break;
  518. bStringValid = true;
  519. }while(false);
  520. if( !bStringValid )
  521. {
  522. SA_DisplayErr("<%=Server.HTMLEncode(L_HOMEDIRECTORY_ERRORMESSAGE) %>");
  523. document.frmTask.onkeypress = ClearErr;
  524. return false;
  525. }
  526. }
  527. return true;
  528. }
  529. // function to make the Ok button disable
  530. function makeDisable(objUsername)
  531. {
  532. var strUsername=objUsername.value;
  533. if (Trim(strUsername)== "")
  534. DisableOK()
  535. else
  536. EnableOK();
  537. }
  538. function checkClick()
  539. {
  540. if( document.frmTask.chkHomePath.checked == true )
  541. {
  542. document.frmTask.txtHomeDirectory.style.backgroundColor = document.frmTask.style.backgroundColor;
  543. document.frmTask.txtHomeDirectory.value =
  544. document.frmTask.hdnDefaultDir.value + document.frmTask.txtUserName.value;
  545. document.frmTask.txtHomeDirectory.disabled = false;
  546. document.frmTask.chkHomePath.value = "checked";
  547. document.frmTask.txtHomeDirectory.focus();
  548. }
  549. else
  550. {
  551. document.frmTask.txtHomeDirectory.style.backgroundColor = 0xD3D3D3;
  552. document.frmTask.txtHomeDirectory.value = "";
  553. document.frmTask.txtHomeDirectory.disabled = true;
  554. document.frmTask.chkHomePath.value = "unchecked";
  555. }
  556. }
  557. // SetData Function
  558. function SetData()
  559. {
  560. //alert("SetData()");
  561. }
  562. </script>
  563. <%
  564. End Function
  565. %>