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.

1474 lines
46 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' id_prop.asp: Page for changing the Device Name and Domain Name
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 21-Jul-2000 Created date
  11. ' 05-Mar-2001 Modified date
  12. ' 24-Mar-2001 Modified date
  13. '-------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp" -->
  16. <!-- #include file="loc_deviceid.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. ' Form Variables
  20. '-------------------------------------------------------------------------
  21. Dim F_strDeviceName 'Device Name from the form
  22. Dim F_strAppleTalkName 'Name of Computer in Apple Talk
  23. Dim F_strNetWareName 'Name of Computer in NetWare
  24. Dim F_strWorkGroup 'Workgroup Name
  25. Dim F_strDomain 'Domain Name
  26. Dim F_strDefaultDNS 'Default DNS
  27. Dim F_strUserName 'User Name
  28. Dim F_strPassword 'Password
  29. Dim F_strRadio 'Radio button value(Workgroup/Domain)
  30. Dim F_strOriginalStatus 'variable for storing original status of
  31. 'the machine(Workgroup/Domain)
  32. Dim F_strRebootState 'Indicate if Reboot required or not
  33. '-------------------------------------------------------------------------
  34. ' Global Variables
  35. '-------------------------------------------------------------------------
  36. Dim page 'Variable that receives the output page object when
  37. 'creating a page
  38. Dim rc 'Return value for CreatePage
  39. Dim G_bAppleTalkInstalled 'Indicate if AppleTalk is installed or not
  40. Dim G_bNetWareInstalled 'Indicate if NetWare is installed or not
  41. '-------------------------------------------------------------------------
  42. ' Error constants
  43. '-------------------------------------------------------------------------
  44. Const N_DUPLICATECOMPUTERNAME_ERRNO1 = &H800708B0
  45. Const N_DUPLICATECOMPUTERNAME_ERRNO2 = &H80070034
  46. Const N_INVALIDDOMAIN_ERRNO = &H8007054B
  47. Const N_DOMAININVALIDDOMAINPERMISSIONDENIES_ERRNO = 70
  48. Const N_INVALIDCREDENTIALS_ERRNO = &H8007052E
  49. Const N_DOMAININVALIDDOMAIN_ERRNO = &H80070520
  50. Const N_UNEXPECTED_COMPUTERNAMEERROR = &H8007092F
  51. Const N_DNSNAMEINVALID_ERRNO = 5
  52. Const N_DOMAINNAMESYSTAX_ERRNO = &H8007007B
  53. Const N_UNSPECIFIED_ERRNO = &H80004005
  54. Const CONST_APPLETALK_SERVICENAME ="MacFile"
  55. Const CONST_NETWARE_SERVICENAME ="FPNW"
  56. Const CONST_HTTPS_OFF ="OFF"
  57. Const CONST_YES ="Yes"
  58. Const CONST_NO ="No"
  59. Const CONST_WORKGROUP ="Workgroup"
  60. Const CONST_DOMAIN ="Domain"
  61. Const CONST_APPLETALK_REGKEYPATH ="SYSTEM\CurrentControlSet\Services\MacFile\Parameters"
  62. Const CONST_NETWARE_REGKEYPATH ="SYSTEM\CurrentControlSet\Services\FPNW\Parameters"
  63. rc = SA_CreatePage(L_TASKTITLE_TEXT, "", PT_PROPERTY, page)
  64. if rc = SA_NO_ERROR then
  65. Call SA_ShowPage(page)
  66. End if
  67. '-------------------------------------------------------------------------
  68. 'Function: OnInitPage()
  69. 'Description: Called to signal first time processing for this page.
  70. ' Used to do first time initialization tasks
  71. 'Input Variables: PageIn,EventArg
  72. 'Output Variables: PageIn,EventArg
  73. 'Returns: True/False
  74. 'Global Variables: F_strRebootState
  75. '-------------------------------------------------------------------------
  76. Public Function OnInitPage(ByRef pageIn, ByRef EventArg)
  77. On Error Resume Next
  78. Err.Clear
  79. Call GetSystemSettings()
  80. Call AppleTalkNetWare()
  81. Call GetAppleTalkNetWareSettings()
  82. F_strRebootState = CONST_NO
  83. OnInitPage = TRUE
  84. End Function 'End of Set Variables From System Function
  85. '-------------------------------------------------------------------------
  86. 'Function: OnServePropertyPage()
  87. 'Description: Called when the page needs to be served.Use this
  88. ' method to serve content
  89. 'Input Variables: PageIn,EventArg
  90. 'Output Variables: None
  91. 'Returns: True/False
  92. 'Global Variables: None
  93. '-------------------------------------------------------------------------
  94. Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  95. %>
  96. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js"></script>
  97. <script language="JavaScript">
  98. var strTemp = "<%=server.HTMLEncode(F_strRadio)%>";
  99. var bAppleDeviceNameEqual = false;
  100. var bNetWareDeviceNameEqual = false;
  101. var strAppleTalkonLoad;
  102. var strNetWareonLoad;
  103. var nNetWareNameLen;
  104. // used as constants
  105. var CONST_APPLETALKNETWARENAME = 1;
  106. var CONST_SANAME = 2;
  107. var CONST_DNSDOMAINNAME = 3;
  108. var CONST_USERNAME = 4;
  109. var CONST_WORKGROUPNAME = 5;
  110. var CONST_DOMAIN = "Domain";
  111. //Init Function
  112. function Init()
  113. {
  114. var objDevicename = document.frmTask.txtdevicename;
  115. var strDeviceName = objDevicename.value;
  116. var strNetWareSliced
  117. //If AppleTalk Installed
  118. "<%IF G_bAppleTalkInstalled = True then %>"
  119. strAppleTalkonLoad = document.frmTask.txtappletalkname.value
  120. //Check if Windows Device Name and AppleTalk DeviceName is the same
  121. if (Trim(strDeviceName).toUpperCase() == Trim(strAppleTalkonLoad).toUpperCase())
  122. {
  123. bAppleDeviceNameEqual = true
  124. }
  125. "<%end if %>"
  126. //If NetWare Installed
  127. "<%IF G_bNetWareInstalled = True then %>"
  128. strNetWareonLoad = document.frmTask.txtnetwarename.value
  129. nNetWareNameLen = Trim(strNetWareonLoad).length
  130. strNetWareSliced = strNetWareonLoad.slice(0,nNetWareNameLen - 3)
  131. //Check if Windows Device Name and NetWare DeviceName is the same
  132. if (Trim(strDeviceName).toUpperCase() == Trim(strNetWareSliced).toUpperCase())
  133. {
  134. bNetWareDeviceNameEqual = true
  135. }
  136. "<%end if %>"
  137. //checking whether for the first time or not
  138. if(Trim(strTemp)=="")
  139. {
  140. //Selects radiobutton value from originalstatus(Machine)
  141. var temp_strOriginalStatus;
  142. temp_strOriginalStatus=document.frmTask.hdnOriginalStatus.value;
  143. }
  144. else
  145. {
  146. temp_strOriginalStatus=strTemp;
  147. }
  148. //checking the Radio button ( domain or workgroup)
  149. if(temp_strOriginalStatus.toUpperCase()==CONST_DOMAIN.toUpperCase())
  150. {
  151. document.frmTask.radiodomainorworkgroup[1].checked=true;
  152. document.frmTask.txtworkgroup.style.backgroundColor="lightgrey";
  153. if(strTemp!="")
  154. {
  155. EnableUserPasswordControls();
  156. document.frmTask.txtdomainusername.style.backgroundColor="";
  157. document.frmTask.pwdomainuserpw.style.backgroundColor="";
  158. }
  159. }
  160. else
  161. {
  162. document.frmTask.radiodomainorworkgroup[0].checked=true;
  163. document.frmTask.txtdomain.style.backgroundColor="lightgrey";
  164. }
  165. if(document.frmTask.txtdomain.value =="")
  166. {
  167. document.frmTask.txtworkgroup.disabled=false;
  168. document.frmTask.txtdomain.disabled =true;
  169. }
  170. else
  171. {
  172. document.frmTask.txtworkgroup.disabled=true;
  173. document.frmTask.txtdomain.disabled =false;
  174. }
  175. //Getting the initial focus to Devicename
  176. document.frmTask.txtdevicename.focus();
  177. SetPageChanged(false);
  178. } /* end of Init */
  179. // validates user entry
  180. function ValidatePage()
  181. {
  182. var objDevicename = document.frmTask.txtdevicename;
  183. var strDeviceName = objDevicename.value;
  184. var objWorkgroup = document.frmTask.txtworkgroup;
  185. var strWorkGroup = objWorkgroup.value;
  186. var objDefaultdns = document.frmTask.txtdefaultdns;
  187. var strDefaultDNS = objDefaultdns.value;
  188. var objDomain = document.frmTask.txtdomain;
  189. var strDomain = objDomain.value;
  190. var objUser = document.frmTask.txtdomainusername;
  191. var strUser = objUser.value;
  192. var arrDomainUser
  193. var strDomainUser
  194. strDeviceName = RTrimtext(LTrimtext(strDeviceName))
  195. strDefaultDNS = RTrimtext(LTrimtext(strDefaultDNS))
  196. strWorkGroup = RTrimtext(LTrimtext(strWorkGroup))
  197. strDomain = RTrimtext(LTrimtext(strDomain))
  198. strUser = RTrimtext(LTrimtext(strUser))
  199. //Validating for empty Hostname
  200. if(Trim(strDeviceName).length<=0)
  201. {
  202. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_DEVICENAMEBLANK_ERRORMESSAGE))%>');
  203. objDevicename.onkeypress=ClearErr;
  204. selectFocus(objDevicename);
  205. return false;
  206. }
  207. //Validating for invalid characters in Hostname
  208. if (!IsComputerNameValid(strDeviceName))
  209. {
  210. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINDEVICENAME_ERRORMESSAGE))%>')
  211. objDevicename.onkeypress=ClearErr;
  212. selectFocus(objDevicename);
  213. return false;
  214. }
  215. //Validating for numbers in Hostname
  216. if(!isNaN(strDeviceName))
  217. {
  218. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_DEVICENAMEISNUMBER_ERRORMESSAGE))%>');
  219. objDevicename.onkeypress=ClearErr;
  220. selectFocus(objDevicename);
  221. return false;
  222. }
  223. // Validating for invalid characters in DNS Suffix
  224. if (!IsDNSNameValid(strDefaultDNS))
  225. {
  226. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINDNSSUFFIX_ERRORMESSAGE))%>')
  227. objDefaultdns.onkeypress=ClearErr;
  228. selectFocus(objDefaultdns);
  229. return false;
  230. }
  231. //Validating for numbers in DNS suffix
  232. if(Trim(strDefaultDNS).length>0 && !isNaN(strDefaultDNS))
  233. {
  234. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_DNSSUFFIXISNUMBER_ERRORMESSAGE))%>');
  235. objDefaultdns.onkeypress=ClearErr;
  236. selectFocus(objDefaultdns);
  237. return false;
  238. }
  239. //Validating for empty Workgroup
  240. if(document.frmTask.radiodomainorworkgroup[0].checked==true &&
  241. Trim(strWorkGroup)=="")
  242. {
  243. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_BLANKWORKGROUP_ERRORMESSAGE))%>');
  244. objWorkgroup.onkeypress=ClearErr;
  245. selectFocus(objWorkgroup);
  246. return false;
  247. }
  248. // Validating for invalid characters in Workgroup
  249. if ((!checkKeyforValidCharacters(strWorkGroup,CONST_WORKGROUPNAME))&&
  250. frmTask.radiodomainorworkgroup[0].checked==true)
  251. {
  252. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINWORKGROUP_ERRORMESSAGE))%>');
  253. objWorkgroup.onkeypress=ClearErr;
  254. selectFocus(objWorkgroup);
  255. return false;
  256. }
  257. //Validating for empty Domain
  258. if(document.frmTask.radiodomainorworkgroup[1].checked==true &&
  259. Trim(strDomain)=="")
  260. {
  261. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_DOMIANNAMEBLANK_ERRORMESSAGE))%>');
  262. objDomain.onkeypress=ClearErr;
  263. selectFocus(objDomain);
  264. return false;
  265. }
  266. // Validating for invalid characters in Domain
  267. if ((!checkKeyforValidCharacters(strDomain,CONST_DNSDOMAINNAME))&&
  268. (frmTask.radiodomainorworkgroup[1].checked==true))
  269. {
  270. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINDOMAIN_ERRORMESSAGE))%>');
  271. objDomain.onkeypress=ClearErr;
  272. selectFocus(objDomain);
  273. return false;
  274. }
  275. // Validating for invalid characters in User
  276. if ( (!checkKeyforValidCharacters(strUser,CONST_USERNAME)) &&
  277. (document.frmTask.radiodomainorworkgroup[1].checked==true))
  278. {
  279. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINUSERNAME_ERRORMESSAGE))%>');
  280. objUser.onkeypress=ClearErr;
  281. selectFocus(objUser);
  282. return false;
  283. }
  284. //Function checks for same Host name and Workgroup
  285. if((document.frmTask.radiodomainorworkgroup[0].checked==true) &&
  286. (strWorkGroup.toUpperCase()==strDeviceName.toUpperCase()))
  287. {
  288. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_HOSTNAMEANDWORKGROUPNAMESAME_ERRORMESSAGE))%>'); objDevicename.onkeypress=ClearErr;
  289. objWorkgroup.onkeypress=ClearErr;
  290. selectFocus(objDevicename);
  291. return false;
  292. }
  293. //Function checks for user name and password when domain checked
  294. //and the values of any field changed
  295. if((document.frmTask.radiodomainorworkgroup[1].checked==true)
  296. &&
  297. (Trim(strUser)=="") && ((Trim(strDomain) !="<%=F_strDomain%>")
  298. ||(strDeviceName !="<%=F_strDeviceName%>")))
  299. {
  300. EnableUserPasswordControls();
  301. document.frmTask.txtdomainusername.style.backgroundColor="";
  302. document.frmTask.pwdomainuserpw.style.backgroundColor="";
  303. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_NOTES_HTML_TEXT))%>');
  304. objDevicename.onkeyup=ClearErr;
  305. objDefaultdns.onkeyup=ClearErr;
  306. objDomain.onkeyup=ClearErr;
  307. objWorkgroup.onkeypress=ClearErr;
  308. objUser.onkeypress=ClearErr;
  309. selectFocus(objUser);
  310. return false;
  311. }
  312. "<%IF G_bAppleTalkInstalled = True then %>"
  313. var objAppleTalkName = document.frmTask.txtappletalkname;
  314. var strAppleTalkName = objAppleTalkName.value;
  315. strAppleTalkName = RTrimtext(LTrimtext(strAppleTalkName))
  316. //Validating for invalid characters in AppleTalk Hostname
  317. if (!checkKeyforValidCharacters(strAppleTalkName,CONST_APPLETALKNETWARENAME))
  318. {
  319. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINAPPLETALKNAME_ERRORMESSAGE))%>')
  320. objAppleTalkName.onkeypress=ClearErr;
  321. selectFocus(objAppleTalkName);
  322. return false;
  323. }
  324. //Validating for empty Hostname
  325. if(Trim(strAppleTalkName)=="")
  326. {
  327. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_APPLETALKNAMEBLANK_ERRORMESSAGE))%>');
  328. objAppleTalkName.onkeypress=ClearErr;
  329. selectFocus(objAppleTalkName);
  330. return false;
  331. }
  332. //Validating for numbers in AppleTalk Hostname
  333. if(!isNaN(strAppleTalkName))
  334. {
  335. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINAPPLETALKNAME_ERRORMESSAGE))%>');
  336. objAppleTalkName.onkeypress=ClearErr;
  337. selectFocus(objAppleTalkName);
  338. return false;
  339. }
  340. "<%end if%>"
  341. "<%IF G_bNetWareInstalled = True then %>"
  342. var objNetWareName = document.frmTask.txtnetwarename;
  343. var strNetWareName = objNetWareName.value;
  344. strNetWareName = RTrimtext(LTrimtext(strNetWareName))
  345. //Validating for invalid characters in NetWare Hostname
  346. if (!checkKeyforValidCharacters(strNetWareName,CONST_APPLETALKNETWARENAME))
  347. {
  348. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINNETWARENAME_ERRORMESSAGE))%>')
  349. objNetWareName.onkeypress=ClearErr;
  350. selectFocus(objNetWareName);
  351. return false;
  352. }
  353. //Validating for empty NetWare Hostname
  354. if(Trim(strNetWareName)=="")
  355. {
  356. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_NETWARENAMEBLANK_ERRORMESSAGE))%>');
  357. objNetWareName.onkeypress=ClearErr;
  358. selectFocus(objNetWareName);
  359. return false;
  360. }
  361. //Validating for numbers in NetWare Hostname
  362. if(!isNaN(strNetWareName))
  363. {
  364. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCHARACTERINNETWARENAME_ERRORMESSAGE))%>');
  365. objNetWareName.onkeypress=ClearErr;
  366. selectFocus(objNetWareName);
  367. return false;
  368. }
  369. //Validating for the Windows Hostname and NetWare Hostname
  370. if (strNetWareName.toUpperCase() == strDeviceName.toUpperCase())
  371. {
  372. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_WINDOWSNETWAREEQUALNAME_ERRORMESSAGE))%>');
  373. selectFocus(objNetWareName);
  374. return false;
  375. }
  376. "<%end if%>"
  377. return true;
  378. }//end of Validate page*/
  379. //Setdata Function for Framework
  380. function SetData()
  381. {
  382. //Disabling Cancel button when user selects OK button
  383. DisableCancel()
  384. "<%IF G_bAppleTalkInstalled = True then %>"
  385. if ( (document.frmTask.txtappletalkname.value).toUpperCase() != (strAppleTalkonLoad).toUpperCase())
  386. {
  387. document.frmTask.hdnRebootState.value = "Yes"
  388. }
  389. "<%end if %>"
  390. "<%IF G_bNetWareInstalled = True then %>"
  391. if ( (document.frmTask.txtnetwarename.value).toUpperCase() != (strNetWareonLoad).toUpperCase() )
  392. {
  393. document.frmTask.hdnRebootState.value = "Yes"
  394. }
  395. "<%end if %>"
  396. }
  397. //This function Disables and enables Workgroup and
  398. //Domain when clicked on the respective radiobuttons
  399. function DisableWorkandDomaingroup(objVal)
  400. {
  401. SetPageChanged(true);
  402. strVal=objVal.value; //assigning the value
  403. if(strVal=="domain")
  404. {
  405. EnableUserPasswordControls();
  406. document.frmTask.txtdomain.disabled = false;
  407. document.frmTask.txtworkgroup.disabled = true;
  408. document.frmTask.txtworkgroup.style.backgroundColor="lightgrey";
  409. document.frmTask.txtdomain.style.backgroundColor="";
  410. document.frmTask.txtdomain.focus();
  411. document.frmTask.txtdomain.select();
  412. }
  413. else
  414. {
  415. document.frmTask.txtworkgroup.disabled = false;
  416. document.frmTask.txtdomain.disabled = true;
  417. document.frmTask.txtworkgroup.focus();
  418. document.frmTask.txtworkgroup.select();
  419. document.frmTask.txtdomainusername.disabled= true;
  420. document.frmTask.pwdomainuserpw.disabled= true;
  421. document.frmTask.txtworkgroup.style.backgroundColor="";
  422. document.frmTask.txtdomain.style.backgroundColor="lightgrey";
  423. document.frmTask.txtdomainusername.style.backgroundColor="lightgrey";
  424. document.frmTask.pwdomainuserpw.style.backgroundColor="lightgrey";
  425. }
  426. }
  427. function IsComputerNameValid(strName)
  428. {
  429. try
  430. {
  431. var pattern = "[^A-Z0-9-]";
  432. var exp = new RegExp(pattern, "i");
  433. var rc = exp.test(strName);
  434. if ( rc == null )
  435. {
  436. return false;
  437. }
  438. else
  439. {
  440. //
  441. // If the test was successful then the
  442. // input contained invalid data.
  443. return ( rc ? false : true);
  444. }
  445. }
  446. catch(oException)
  447. {
  448. return false;
  449. }
  450. }
  451. function IsDNSNameValid(strName)
  452. {
  453. try
  454. {
  455. var pattern = "[^A-Z0-9-\.]";
  456. var exp = new RegExp(pattern, "i");
  457. var rc = exp.test(strName);
  458. if ( rc == null )
  459. {
  460. return false;
  461. }
  462. else
  463. {
  464. //
  465. // If the test was successful then the
  466. // input contained invalid data.
  467. return ( rc ? false : true);
  468. }
  469. }
  470. catch(oException)
  471. {
  472. return false;
  473. }
  474. }
  475. //To check for Invalid Characters
  476. function checkKeyforValidCharacters(strName,nType)
  477. {
  478. var nLength = strName.length;
  479. var nFwdslashCount = 0
  480. if (nLength > 0)
  481. {
  482. var colonvalue;
  483. colonvalue = 0;
  484. //Validating DNS and Domain names
  485. if (nType == CONST_DNSDOMAINNAME)
  486. {
  487. for(var i=0; i<nLength;i++)
  488. {
  489. charAtPos = strName.charCodeAt(i);
  490. if(charAtPos == 47 || charAtPos == 92 || charAtPos ==58 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44 || charAtPos == 32)
  491. {
  492. return false
  493. }
  494. }
  495. }
  496. else
  497. {
  498. //Validating Workgroup name
  499. if (nType == CONST_WORKGROUPNAME)
  500. {
  501. for(var i=0; i<nLength;i++)
  502. {
  503. charAtPos = strName.charCodeAt(i);
  504. if(charAtPos == 47 || charAtPos == 92 || charAtPos ==58 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44 )
  505. {
  506. return false
  507. }
  508. }
  509. }
  510. else
  511. {
  512. //Validating User name
  513. if(nType == CONST_USERNAME)
  514. {
  515. for(var i=0; i<nLength;i++)
  516. {
  517. charAtPos = strName.charCodeAt(i);
  518. if (charAtPos == 47 || charAtPos ==58 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44 || charAtPos == 46)
  519. {
  520. return false
  521. }
  522. if (charAtPos == 92)
  523. {
  524. nFwdslashCount = nFwdslashCount + 1
  525. if (nFwdslashCount > 1 )
  526. {
  527. return false
  528. }
  529. }
  530. }
  531. }
  532. else
  533. {
  534. //Validating for AppleTalk and NetWare names
  535. if(nType == CONST_APPLETALKNETWARENAME)
  536. {
  537. for(var i=0; i<nLength;i++)
  538. {
  539. charAtPos = strName.charCodeAt(i);
  540. if (charAtPos == 47 || charAtPos == 92 || charAtPos ==58 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44 || charAtPos == 46 || charAtPos == 32)
  541. {
  542. return false
  543. }
  544. }
  545. }
  546. else
  547. {
  548. //Validation for Server appliance name
  549. if(nType == CONST_SANAME)
  550. {
  551. for(var i=0; i<nLength;i++)
  552. {
  553. charAtPos = strName.charCodeAt(i);
  554. if (charAtPos == 47 || charAtPos == 92 || charAtPos ==58 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44 || charAtPos == 46 || charAtPos == 32 || charAtPos == 33 || charAtPos == 39)
  555. {
  556. return false
  557. }
  558. }
  559. }
  560. else
  561. {
  562. for(var i=0; i<nLength;i++)
  563. {
  564. charAtPos = strName.charCodeAt(i);
  565. if(charAtPos == 58)
  566. {
  567. return false
  568. }
  569. }
  570. }
  571. }
  572. }
  573. }
  574. }
  575. }
  576. return true
  577. }
  578. //This Function enables the DomainUsername and Password
  579. function EnableUserPasswordControls()
  580. {
  581. if(document.frmTask.radiodomainorworkgroup[1].checked==true)
  582. {
  583. document.frmTask.txtdomainusername.disabled = false;
  584. document.frmTask.pwdomainuserpw.disabled = false;
  585. document.frmTask.txtdomainusername.style.backgroundColor="";
  586. document.frmTask.pwdomainuserpw.style.backgroundColor="";
  587. }
  588. }
  589. //For Device Name Change
  590. function OnDeviceNameChange()
  591. {
  592. SetPageChanged(true);
  593. EnableUserPasswordControls();
  594. "<%IF G_bAppleTalkInstalled = True then %>"
  595. if (bAppleDeviceNameEqual == true)
  596. {
  597. document.frmTask.txtappletalkname.value = document.frmTask.txtdevicename.value
  598. }
  599. "<%End If%>"
  600. "<%IF G_bNetWareInstalled = True then %>"
  601. if (bNetWareDeviceNameEqual == true)
  602. {
  603. document.frmTask.txtnetwarename.value = document.frmTask.txtdevicename.value + "_NW"
  604. }
  605. "<%End If%>"
  606. }
  607. //------------------------------------------------------------------------
  608. // Function :LTrimtext
  609. // Description :function to remove left trailing spaces
  610. // input :String
  611. // returns :String
  612. //------------------------------------------------------------------------
  613. function LTrimtext(str)
  614. {
  615. var res="", i, ch, index;
  616. x = str.length;
  617. index = "false";
  618. for (i=0; i < str.length; i++)
  619. {
  620. ch = str.charAt(i);
  621. if (index == "false")
  622. {
  623. if (ch != ' ')
  624. {
  625. index = "true";
  626. res = ch;
  627. }
  628. }
  629. else
  630. {
  631. res = res + ch;
  632. }
  633. }
  634. return res;
  635. }
  636. //------------------------------------------------------------------------
  637. // Function :RTrimtext
  638. // Description :function to remove right trailing spaces
  639. // input :String
  640. // returns :String
  641. //------------------------------------------------------------------------
  642. function RTrimtext(str)
  643. {
  644. var res="", i, ch, index, j, k;
  645. x = str.length;
  646. index = "false";
  647. if(x==0 || x==1)
  648. return str;
  649. for(i=x; i >= 0; i--)
  650. {
  651. ch = str.charAt(i);
  652. if (index == "false")
  653. {
  654. if( (ch == ' ') || (ch == '') )
  655. {
  656. continue;
  657. }
  658. else
  659. {
  660. index = "true";
  661. j = i;
  662. }
  663. }
  664. if (index == "true")
  665. {
  666. for(k=0; k<=j; k++)
  667. {
  668. res = res + str.charAt(k);
  669. }
  670. return res;
  671. }
  672. }
  673. }
  674. </script>
  675. <table border="0" cellspacing="0" cellpadding="0" width=50%>
  676. <tr>
  677. <td class="TasksBody" colspan="4">
  678. <%CheckForSecureSite()%>
  679. <br>
  680. </td>
  681. </tr>
  682. <tr>
  683. <td class="TasksBody" nowrap>
  684. <%=server.HTMLEncode(L_DEVICENAME_TEXT)%>
  685. </td>
  686. <td class="TasksBody" nowrap colspan="3">
  687. <input type="text" name="txtdevicename" class="FormField" onKeyUP="OnDeviceNameChange()" size="25" maxlength="63"
  688. value="<%=server.HTMLEncode(F_strDeviceName)%>"
  689. >
  690. </td>
  691. </tr>
  692. <tr>
  693. <td class="TasksBody" nowrap>
  694. <%=server.HTMLEncode(L_DEFAULTDNS_TEXT)%>
  695. </td>
  696. <td class="TasksBody" nowrap colspan="3">
  697. <input type="text" name="txtdefaultdns" class="FormField" onChange="SetPageChanged(true);" size="25" maxlength="155"
  698. value="<%=server.HTMLEncode(F_strDefaultDNS)%>" >
  699. </td>
  700. </tr>
  701. <tr>
  702. <td class="TasksBody" colspan="4">
  703. <hr>
  704. </td>
  705. </tr>
  706. <tr>
  707. <td class="TasksBody" nowrap >
  708. <%=server.HTMLEncode(L_MEMBEROF_TEXT)%>
  709. </td>
  710. <td class="TasksBody" nowrap colspan="2" >
  711. <input type="radio" name="radiodomainorworkgroup" class="FormRadioButton" value="workgroup"
  712. onClick="DisableWorkandDomaingroup(this)" >
  713. <%=server.HTMLEncode(L_WORKGROUP_TEXT)%>
  714. </td>
  715. <td class="TasksBody" nowrap >
  716. <input type="text" name="txtworkgroup" class="FormField" onChange="SetPageChanged(true);" size="25" maxlength="15"
  717. value="<%=server.HTMLEncode(F_strWorkGroup)%>" >
  718. </td>
  719. </tr>
  720. <tr>
  721. <td class="TasksBody" nowrap> &nbsp;
  722. </td>
  723. <td class="TasksBody" nowrap colspan="2">
  724. <input type="radio" name="radiodomainorworkgroup" class="FormRadioButton" value="domain"
  725. onClick="DisableWorkandDomaingroup(this);" >
  726. <%=server.HTMLEncode(L_DOMAIN_TEXT) %>
  727. </td>
  728. <td class="TasksBody" nowrap>
  729. <input type="text" name="txtdomain" class="FormField" onKeyUP="EnableUserPasswordControls();" size="25" maxlength="155"
  730. value="<%=server.HTMLEncode(F_strDomain)%>" >
  731. </td>
  732. </tr>
  733. <tr>
  734. <td class="TasksBody" nowrap>&nbsp;
  735. </td>
  736. <td class="TasksBody" colspan="3">
  737. <%=Server.HTMLEncode(L_USERWITHPERMISSION_TEXT)%>
  738. </td>
  739. </tr>
  740. <tr>
  741. <td class="TasksBody" nowrap width="20%">&nbsp;
  742. </td>
  743. <td class="TasksBody" nowrap width="3%">&nbsp;
  744. </td>
  745. <td class="TasksBody" nowrap width="15%">
  746. <%=Server.HTMLEncode(L_ADMINUSERNAME_TEXT)%>
  747. </td>
  748. <td class="TasksBody" nowrap >
  749. <input type="text" class="FormField" name="txtdomainusername" onChange="SetPageChanged(true);" onKeyPress="ClearErr();" value="<%=server.HTMLEncode(F_strUserName)%>" size="25" maxlength="256" disabled style="background-color:lightgrey">
  750. </td>
  751. </tr>
  752. <tr>
  753. <td class="TasksBody" nowrap>&nbsp;
  754. </td>
  755. <td class="TasksBody" nowrap>&nbsp;
  756. </td>
  757. <td class="TasksBody" nowrap>
  758. <%=Server.HTMLEncode(L_ADMINPASSWORD_TEXT)%>
  759. </td>
  760. <td class="TasksBody" nowrap>
  761. <input type="password" name="pwdomainuserpw" class="FormField" onChange="SetPageChanged(true);" size="25" maxlength="35" disabled style="background-color:lightgrey">
  762. </td>
  763. </tr>
  764. <tr>
  765. <td class="TasksBody" >
  766. &nbsp;
  767. </td>
  768. </tr>
  769. <tr>
  770. <td class="TasksBody" colspan="4">
  771. <hr>
  772. </td>
  773. </tr>
  774. <% If G_bAppleTalkInstalled = True then %>
  775. <tr>
  776. <td class="TasksBody" nowrap>
  777. <%=server.HTMLEncode(L_APPLETALKNAME_TEXT)%>
  778. </td>
  779. <td class="TasksBody" colspan="3">
  780. <input type="text" name="txtappletalkname" class="FormField" size="25" maxlength="31"
  781. value="<%=Server.HTMLEncode(F_strAppleTalkName)%>" >
  782. </td>
  783. </tr>
  784. <% End If %>
  785. <% IF G_bNetWareInstalled = True then %>
  786. <tr>
  787. <td class="TasksBody" nowrap>
  788. <%=server.HTMLEncode(L_NETWARENAME_TEXT)%>
  789. </td>
  790. <td class="TasksBody" colspan="3">
  791. <input type="text" name="txtnetwarename" class="FormField" size="25" maxlength="47"
  792. value="<%=Server.HTMLEncode(F_strNetWareName)%>" >
  793. </td>
  794. </tr>
  795. <% End If %>
  796. </table>
  797. <input type="hidden" name="hdnOriginalStatus" value="<%=F_strOriginalStatus%>">
  798. <input type="hidden" name="hdnRebootState" value="<%=F_strRebootState%>">
  799. <%
  800. OnServePropertyPage = True
  801. End Function
  802. '-------------------------------------------------------------------------
  803. 'Function: OnPostBackPage()
  804. 'Description: Called to signal that the page has been posted-back.
  805. 'Input Variables: PageIn, EventArg
  806. 'Output Variables: PageIn, EventArg, F_(*)
  807. 'Returns: True/False
  808. 'Global Variables: F_(*)
  809. '-------------------------------------------------------------------------
  810. Public Function OnPostBackPage(ByRef PageIn,ByRef EventArg)
  811. F_strDeviceName = Trim(Request.Form("txtdevicename"))
  812. F_strAppleTalkName = Trim(Request.Form("txtappletalkname"))
  813. F_strNetWareName = Trim(Request.Form("txtnetwarename"))
  814. F_strWorkGroup = Trim(Request.Form("txtworkgroup"))
  815. F_strDomain = Trim(Request.Form("txtdomain"))
  816. F_strDefaultDNS = Trim(Request.Form("txtdefaultdns"))
  817. F_strUserName = Trim(Request.Form("txtdomainusername"))
  818. F_strPassword = Trim(Request.Form("pwdomainuserpw"))
  819. F_strRadio = Trim(Request.Form("radiodomainorworkgroup"))
  820. F_strOriginalStatus = Trim(Request.Form("hdnOriginalStatus"))
  821. F_strRebootState = Trim(Request.Form("hdnRebootState"))
  822. OnPostBackPage = TRUE
  823. End Function
  824. '-----------------------------------------------------------------------------
  825. 'Function: OnSubmitPage()
  826. 'Description: Called when the page has been submitted for processing.
  827. ' Use this method to process the submit request.
  828. 'Input Variables: PageIn, EventArg
  829. 'Output Variables: PageIn, EventArg
  830. 'Returns: True/False
  831. 'Global Variables: None
  832. '-----------------------------------------------------------------------------
  833. Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  834. Dim objSystem 'System Object
  835. Set objSystem = CreateObject("comhelper.SystemSetting")
  836. If not SetSystemSettings(objSystem) then
  837. onSubmitPage = False
  838. Set objSystem = nothing
  839. Exit Function
  840. End If
  841. Call AppleTalkNetWare()
  842. If not IsRestartReq(objSystem) Then
  843. onSubmitPage = False
  844. Set objSystem = nothing
  845. Exit Function
  846. End If
  847. Set objSystem = nothing
  848. OnSubmitPage = True
  849. End Function
  850. '-------------------------------------------------------------------------
  851. 'Function: OnClosePage()
  852. 'Description: Called when the page is about to be closed.Use this
  853. ' method to perform clean-up processing
  854. 'Input Variables: PageIn,EventArg
  855. 'Output Variables: None
  856. 'Returns: True/False
  857. 'Global Variables: None
  858. '-------------------------------------------------------------------------
  859. Public Function OnClosePage(ByRef PageIn,ByRef EventArg)
  860. OnClosePage=TRUE
  861. End Function
  862. '-------------------------------------------------------------------------
  863. 'Sub routine: AppleTalkNetWare
  864. 'Description: To check whether required services are installed or not
  865. 'Input Variables: None
  866. 'Output Variables: None
  867. 'Returns: None
  868. 'Global Variables: Out:G_bAppleTalkInstalled
  869. ' Out:G_bNetWareInstalled
  870. ' In:CONST_APPLETALK_SERVICENAME
  871. ' In:CONST_NETWARE_SERVICENAME
  872. ' In:CONST_WMI_WIN32_NAMESPACE
  873. ' In:L_(*)
  874. '-------------------------------------------------------------------------
  875. Sub AppleTalkNetWare()
  876. On Error Resume Next
  877. Err.Clear
  878. Dim objWMIConnection
  879. Dim strProtocol
  880. Dim strPath
  881. Dim strServerName
  882. Set objWMIConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  883. 'Incase connection fails
  884. If Err.number <> 0 Then
  885. Call SA_ServeFailurePageEx(L_FAILEDTOGETWMICONNECTION_ERRORMESSAGE, mstrReturnURL )
  886. Exit Sub
  887. End If
  888. G_bAppleTalkInstalled = SA_IsServiceInstalled(CONST_APPLETALK_SERVICENAME)
  889. G_bNetWareInstalled = SA_IsServiceInstalled(CONST_NETWARE_SERVICENAME)
  890. Set objWMIConnection = nothing
  891. End Sub
  892. '-------------------------------------------------------------------------
  893. 'Function: GetSystemSettings
  894. 'Description: To get the System Settings using a Com Object
  895. 'Input Variables: None
  896. 'Output Variables: None
  897. 'Returns: None
  898. 'Global Variables: F_(*), L_ERROROCCUREDINCREATEOBJECT_ERRORMESSAGE
  899. ' L_ERRORINGETTINGCOMPUTERSYSTEMOBJECT_ERRORMESSAGE
  900. '-------------------------------------------------------------------------
  901. Function GetSystemSettings()
  902. On Error Resume Next
  903. Err.Clear
  904. Dim objSystem
  905. Dim objComputer
  906. Set objSystem = CreateObject("comhelper.SystemSetting")
  907. If Err.Number <> 0 Then
  908. Call SA_ServeFailurePageEx(L_ERROROCCUREDINCREATEOBJECT_ERRORMESSAGE, mstrReturnURL)
  909. Exit Function
  910. End If
  911. Set objComputer = objSystem.Computer
  912. If Err.Number <> 0 Then
  913. Call SA_ServeFailurePageEx(L_ERRORINGETTINGCOMPUTERSYSTEMOBJECT_ERRORMESSAGE, mstrReturnURL )
  914. Exit Function
  915. End If
  916. F_strDeviceName = objComputer.ComputerName
  917. F_strDomain = objComputer.DomainName
  918. 'Incase Domain returns null then an error number -2147467259
  919. If Err.number = N_UNSPECIFIED_ERRNO then
  920. Err.Clear
  921. End If
  922. F_strWorkGroup = objComputer.WorkgroupName
  923. 'Incase Workgroup returns null then an error number -2147467259
  924. If Err.number = N_UNSPECIFIED_ERRNO then
  925. Err.Clear
  926. End If
  927. F_strDefaultDNS = objComputer.FullQualifiedComputerName
  928. LTrim(F_strDomain)
  929. LTrim(F_strWorkGroup)
  930. 'Assigning the original status(Domain/Workgroup)
  931. If LTrim(F_strDomain) <> "" Then
  932. F_strOriginalStatus = CONST_DOMAIN
  933. Else
  934. F_strOriginalStatus = CONST_WORKGROUP
  935. End If
  936. 'Assigning the DNS value
  937. If IsNull(F_strDefaultDNS) = False Then
  938. Dim DNSlen, Devicelen
  939. DNSlen = Len(F_strDefaultDNS)
  940. Devicelen = Len(F_strDeviceName)
  941. DNSlen = DNSlen - Devicelen - 1
  942. If DNSlen < 0 Then
  943. DNSlen = 0
  944. End If
  945. F_strDefaultDNS = Right(F_strDefaultDNS, DNSlen)
  946. End If
  947. Set objComputer = Nothing
  948. Set objSystem = Nothing
  949. End Function
  950. '-------------------------------------------------------------------------
  951. 'Function: SetSystemSettings
  952. 'Description: To set the System Settings using a Com Object
  953. 'Input Variables: objSystem
  954. 'Output Variables: None
  955. 'Returns: True/False
  956. 'Global Variables: F_(*), L_ERROROCCUREDINCREATEOBJECT_ERRORMESSAGE
  957. ' L_ERRORINGETTINGCOMPUTERSYSTEMOBJECT_ERRORMESSAGE
  958. ' L_LOGONINFOFAILED_ERRORMESSAGE
  959. '-------------------------------------------------------------------------
  960. Function SetSystemSettings(objSystem)
  961. On Error Resume Next
  962. Err.Clear
  963. Dim objComputer
  964. SetSystemSettings = False
  965. If Err.Number <> 0 Then
  966. SA_SetErrMsg L_ERROROCCUREDINCREATEOBJECT_ERRORMESSAGE &_
  967. "( " & Hex(Err.number)& " )"
  968. objComputer = nothing
  969. Exit Function
  970. End If
  971. 'get the computer object
  972. Set objComputer=objSystem.Computer
  973. If Err.Number <> 0 Then
  974. SA_SetErrMsg L_ERRORINGETTINGCOMPUTERSYSTEMOBJECT_ERRORMESSAGE &_
  975. "(" & Hex(Err.Number)& " )"
  976. objComputer = nothing
  977. Exit Function
  978. End If
  979. 'Assigning the Host name
  980. objComputer.ComputerName=F_strDeviceName
  981. 'If DNS Suffix is not empty/If DNS Suffix is empty
  982. If F_strDefaultDNS <> "" Then
  983. objComputer.FullQualifiedComputerName=F_strDeviceName & "."& F_strDefaultDNS
  984. Else
  985. objComputer.FullQualifiedComputerName=F_strDeviceName
  986. End If
  987. 'Machine belongs to Workgroup
  988. 'If F_strOriginalStatus = "workgroup" then
  989. If ( UCase(F_strOriginalStatus) = UCase(CONST_WORKGROUP)) then
  990. 'Adding to Workgroup
  991. If (UCase(F_strRadio) = UCase(CONST_WORKGROUP)) then
  992. objComputer.workgroupName = F_strWorkGroup
  993. 'Adding to Domain
  994. Elseif (UCase(F_strRadio) = UCase(CONST_DOMAIN) ) then
  995. objcomputer.domainName = F_strDomain
  996. End If
  997. 'Machine belongs to Domain
  998. Else
  999. 'Adding to Workgroup
  1000. If (UCase(F_strRadio) = UCase(CONST_WORKGROUP)) then
  1001. objComputer.workgroupName = F_strWorkGroup
  1002. 'Adding to Domain
  1003. Elseif (UCase(F_strRadio) = UCase(CONST_DOMAIN) ) then
  1004. objcomputer.domainName = F_strDomain
  1005. End If
  1006. End If
  1007. 'In XPE, to join a domain, the username has to be domain\username
  1008. If CONST_OSNAME_XPE = GetServerOSName() Then
  1009. if (UCase(F_strRadio) = UCase(CONST_DOMAIN) ) then
  1010. if InStr(F_strUserName, "\") = 0 Then
  1011. F_strUserName = F_strDomain & "\" & F_strUserName
  1012. End If
  1013. End If
  1014. End If
  1015. 'Logon information(Username & Password)
  1016. objComputer.LogonInfo F_strUserName,F_strPassword
  1017. 'Checking for logoninfo method failure
  1018. If Err.number <> 0 Then
  1019. SA_SetErrMsg L_LOGONINFOFAILED_ERRORMESSAGE &_
  1020. "("& Hex(Err.Number) &")"
  1021. objComputer = nothing
  1022. Exit Function
  1023. End If
  1024. Set objComputer = nothing
  1025. SetSystemSettings = True
  1026. End Function
  1027. '---------------------------------------------------------------------
  1028. 'Function name: ApplySettings
  1029. 'Description: Applies the settings for the System
  1030. 'Input Variables: objSystem
  1031. 'Output Variables: None
  1032. 'Return Values: Returns (True/False)
  1033. 'Global Variables: In:L_(*)
  1034. ' In:N_(*)
  1035. '---------------------------------------------------------------------
  1036. Function ApplySettings(objSystem)
  1037. on error resume next
  1038. Err.Clear
  1039. Dim errorcode
  1040. Dim strErrorMessage
  1041. ApplySettings = FALSE
  1042. SA_TraceOut "ID_PROP", "Beginning ApplySettings"
  1043. If ( Err.Number <> 0 ) Then
  1044. SA_TraceOut "ID_PROP", "Precondition assert failed. Err.Number != 0 " + CStr(Hex(Err.Number))
  1045. End If
  1046. 'Apply System Settings using ComObject
  1047. objSystem.Apply(1)
  1048. errorCode = Err.Number
  1049. If errorCode = 0 Then
  1050. If ( G_bAppleTalkInstalled ) Then 'If AppleTalk service installed
  1051. 'Function call to set the servername in the regisrty
  1052. If not IsSetServerNameInRegistry(CONST_APPLETALK_REGKEYPATH,"ServerName",F_strAppleTalkName) Then
  1053. ApplySettings = False
  1054. Exit function
  1055. End If
  1056. End If ' end of If ( G_bAppleTalkInstalled ) Then
  1057. If ( G_bNetWareInstalled ) Then 'If Netware service installed
  1058. 'Function call to set the servername in the regisrty
  1059. If not IsSetServerNameInRegistry(CONST_NETWARE_REGKEYPATH,"ComputerName",F_strNetWareName) Then
  1060. ApplySettings = False
  1061. Exit function
  1062. End If
  1063. End If ' end of If ( G_bNetWareInstalled ) Then
  1064. ApplySettings = TRUE
  1065. Else
  1066. ApplySettings = FALSE
  1067. SA_TraceOut "ID_PROP", "objSystem.Apply(1) failed: " + CStr(Hex(errorCode))
  1068. Select Case errorCode
  1069. Case N_UNEXPECTED_COMPUTERNAMEERROR
  1070. strErrorMessage = L_COMPUTERNAME_INVALID_ERRORMESSAGE
  1071. Case N_DUPLICATECOMPUTERNAME_ERRNO1
  1072. strErrorMessage = L_COMPUTERNAME_INUSE_ERRORMESSAGE
  1073. Case N_DUPLICATECOMPUTERNAME_ERRNO2
  1074. strErrorMessage = L_COMPUTERNAME_INUSE_ERRORMESSAGE
  1075. Case N_INVALIDDOMAIN_ERRNO
  1076. strErrorMessage = L_INVALIDDOMAINNAME_ERRORMESSAGE
  1077. Case N_INVALIDCREDENTIALS_ERRNO
  1078. strErrorMessage = L_DOMAINUSERINVALIDCREDENTIALS_ERRORMESSAGE
  1079. Case N_DOMAININVALIDDOMAIN_ERRNO
  1080. strErrorMessage = L_DOMAINUSERINVALIDCREDENTIALS_ERRORMESSAGE
  1081. Case N_DOMAININVALIDDOMAINPERMISSIONDENIES_ERRNO
  1082. strErrorMessage = L_DOMAINUSERINVALIDCREDENTIALS_ERRORMESSAGE
  1083. Case N_DNSNAMEINVALID_ERRNO
  1084. strErrorMessage = L_INVALIDDNSNAME_ERRORMESSAGE
  1085. Case N_DOMAINNAMESYSTAX_ERRNO
  1086. strErrorMessage = L_DOMAINNAMESYNTAX_ERRORMESSAGE
  1087. Case Else
  1088. strErrorMessage = L_CHANGESYSTEMSETTINGSFAILED_ERRORMESSAGE
  1089. End Select
  1090. strErrorMessage = strErrorMessage & " ("& Hex(errorCode) &")"
  1091. SA_SetErrMsg strErrorMessage
  1092. End If
  1093. End Function
  1094. '------------------------------------------------------------------------
  1095. 'Subroutine name: IsRestartReq
  1096. 'Description: To check if restart required or not
  1097. 'Input Variables: objSystem
  1098. 'Ouput Variables: None
  1099. 'Return Values: True/False
  1100. 'Global Variables: L_ERRORINISREBOOT_ERRORMESSAGE, F_strRebootState
  1101. ' : L_CHANGESYSTEMSETTINGSFAILED_ERRORMESSAGE
  1102. '------------------------------------------------------------------------
  1103. Function IsRestartReq(objSystem)
  1104. On Error Resume Next
  1105. Err.Clear
  1106. Dim nIsRestartReq
  1107. Dim strReturnURL
  1108. Dim strMessage
  1109. strReturnURL = "RebootSys.asp"
  1110. 'Is Restart Required
  1111. nIsRestartReq = objSystem.IsRebootRequired(strMessage)
  1112. If Err.Number <> 0 Then
  1113. SA_SetErrMsg L_ERRORINISREBOOT_ERRORMESSAGE &_
  1114. "("& Hex(Err.Number) &")"
  1115. objSystem = nothing
  1116. IsRestartReq = False
  1117. Exit Function
  1118. End If
  1119. '
  1120. ' If restart not required for this change
  1121. If (NOT nIsRestartReq) Then
  1122. ' Make sure the last attempt did not require a reboot
  1123. If (UCase(F_strRebootState) = UCase(CONST_YES)) Then
  1124. SA_TraceOut "ID_PROP", "Cached reboot state being set"
  1125. nIsRestartReq = 1
  1126. End If
  1127. End If
  1128. If nIsRestartReq Then 'If restart required then assign all the
  1129. SA_TraceOut "ID_PROP", "Reboot is required"
  1130. F_strRebootState = CONST_YES
  1131. SA_TraceOut "ID_PROP", "Calling ApplySettings"
  1132. If ApplySettings(objSystem) = TRUE Then 'Calling the applysettings method
  1133. SA_TraceOut "ID_PROP", "Redirecting to RebootSys.asp"
  1134. 'Redirecting to reboot page
  1135. Call SA_MungeURL(strReturnURL,"Tab1",getTab1())
  1136. Call SA_MungeURL(strReturnURL,"Tab2",getTab2())
  1137. Call SA_MungeURL(strReturnURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  1138. Response.Redirect strReturnURL
  1139. Else
  1140. SA_TraceOut "ID_PROP", "ApplySettings failed "
  1141. objSystem = nothing
  1142. Exit Function
  1143. End If
  1144. Else
  1145. SA_TraceOut "ID_PROP", "Reboot is NOT required"
  1146. objSystem.Apply(1) 'Applying the settings to object
  1147. If Err.Number <> 0 Then
  1148. SA_SetErrMsg L_CHANGESYSTEMSETTINGSFAILED_ERRORMESSAGE &_
  1149. "("& Hex(Err.Number) &")"
  1150. IsRestartReq = False
  1151. objSystem = nothing
  1152. Exit Function
  1153. End If
  1154. End If
  1155. IsRestartReq = True
  1156. End Function
  1157. '-----------------------------------------------------------------------
  1158. 'Subroutine name: GetAppleTalkNetWareSettings
  1159. 'Description: To get AppleTalk and NetWare Settings from the
  1160. ' Registry
  1161. 'Input Variables: G_bAppleTalkInstalled, G_bNetWareInstalled
  1162. ' F_strDeviceName
  1163. 'Ouput Variables: F_strNetWareName, F_strAppleTalkName
  1164. 'Return Values: None
  1165. 'Global Variables: G_bAppleTalkInstalled, G_bNetWareInstalled,
  1166. ' F_strAppleTalkName, F_strNetWareName, F_strDeviceName
  1167. '------------------------------------------------------------------------
  1168. Function GetAppleTalkNetWareSettings
  1169. On Error Resume Next
  1170. Err.Clear
  1171. Dim strPath
  1172. Dim strServerName
  1173. Dim objAppleNetwareRegistry
  1174. GetAppleTalkNetWareSettings = False
  1175. If G_bAppleTalkInstalled = True or G_bNetWareInstalled = True Then
  1176. set objAppleNetwareRegistry = RegConnection()
  1177. If Err.number <> 0 then
  1178. SA_SetErrMsg L_REGISTRYCONNECTIONFAIL_ERRORMESSAGE & "(" & Err.Number & ")"
  1179. Exit Function
  1180. End If
  1181. If G_bAppleTalkInstalled = True Then
  1182. strPath = "SYSTEM\CurrentControlSet\Services\MacFile\Parameters"
  1183. strServerName = getRegkeyvalue(objAppleNetwareRegistry,strPath,"ServerName",CONST_STRING)
  1184. 'Checking for the AppleTalk servername
  1185. If strServerName = "" Then
  1186. F_strAppleTalkName = F_strDeviceName 'if null assign the machine name itself
  1187. Else
  1188. F_strAppleTalkName = strServerName 'Get it from the registry
  1189. End IF
  1190. End If
  1191. If G_bNetWareInstalled = True Then
  1192. strPath = "SYSTEM\CurrentControlSet\Services\FPNW\Parameters"
  1193. strServerName = getRegkeyvalue(objAppleNetwareRegistry,strPath,"ComputerName",CONST_STRING)
  1194. 'Checking for the Netware servername
  1195. If strServerName = "" Then
  1196. F_strNetWareName = F_strDeviceName & "_NW" 'if null assign the machine name itself
  1197. Else
  1198. F_strNetWareName = strServerName 'Get it from the registry
  1199. End IF
  1200. End If
  1201. End If
  1202. GetAppleTalkNetWareSettings = True
  1203. End Function
  1204. '-----------------------------------------------------------------------
  1205. 'Function: IsSetServerNameInRegistry
  1206. 'Description: To set Server names like AppleTalk and NetWare in Registry
  1207. 'Input Variables: strRegkeyPath -Path
  1208. ' strKeyName -KeyName
  1209. ' strValue -Keyvalue
  1210. 'Ouput Variables:
  1211. 'Return Values: TRUE/FALSE
  1212. 'Global Variables: In:L_(*)
  1213. '------------------------------------------------------------------------
  1214. Function IsSetServerNameInRegistry(strRegkeyPath , strKeyName , strValue )
  1215. On Error Resume Next
  1216. Err.Clear
  1217. Dim objRegistry
  1218. Dim nReturnValue
  1219. IsSetServerNameInRegistry=TRUE
  1220. Set objRegistry = RegConnection()
  1221. If Err.number <> 0 then
  1222. SA_SetErrMsg L_REGISTRYCONNECTIONFAIL_ERRORMESSAGE
  1223. Exit Function
  1224. End If
  1225. nReturnValue= updateRegkeyvalue(objRegistry , strRegkeyPath , strKeyName , strValue , CONST_STRING )
  1226. If nReturnValue = FAlSE Then
  1227. IsSetServerNameInRegistry=FALSE
  1228. End If
  1229. End function
  1230. %>