Source code of Windows XP (NT5)
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.

117 lines
3.7 KiB

  1. function PageInit()
  2. {
  3. top.window.PopulateLeftPane(null, idLearnAboutContent.innerHTML);
  4. AttachAccountTypeEvents();
  5. // Default account type is Owner
  6. var iAccountType = 0;
  7. // If there are no Owner accounts, in which case we must be running
  8. // as 'Adminstrator', force the admin to create an Owner account.
  9. if (0 == top.window.CountOwners())
  10. {
  11. idLimited.disabled = true;
  12. idCantChange.style.display = 'block';
  13. }
  14. else if (null != top.window.g_iNewType)
  15. iAccountType = top.window.g_iNewType;
  16. var selection = idRadioGroup.children[iAccountType].firstChild;
  17. selection.click();
  18. selection.focus();
  19. }
  20. function CreateAccount()
  21. {
  22. var szName = top.window.g_szNewName;
  23. // Set top.window.g_szNewName to null right away and test for null below
  24. // to prevent strange errors due to double invocation of this function.
  25. // (e.g. if the user hits Enter twice quickly)
  26. top.window.g_szNewName = null;
  27. if (szName && szName.length > 0)
  28. {
  29. var oNewUser = null;
  30. var szLoginName = szName;
  31. // Make sure the login name is unique
  32. for (var n = 2; IsDuplicateLoginName(szLoginName); n++)
  33. szLoginName = szName + "_" + n;
  34. try
  35. {
  36. oNewUser = top.window.g_oUserList.create(szLoginName);
  37. // If we had to futz with the login name, set the display
  38. // name to the original.
  39. if (szName != szLoginName && !IsDuplicateDisplayName(szName))
  40. oNewUser.setting("DisplayName") = szName;
  41. }
  42. catch (error)
  43. {
  44. top.window.g_szNewName = szName;
  45. if ((error.number & 0xffff) == 2202) // ERROR_BAD_USERNAME
  46. {
  47. alert(top.window.L_NameNotValid_ErrorMessage);
  48. top.window.g_Navigator.back();
  49. }
  50. else
  51. throw error;
  52. }
  53. if (oNewUser)
  54. {
  55. var nErr = 0;
  56. try
  57. {
  58. SetAccountType(oNewUser);
  59. }
  60. catch (error)
  61. {
  62. nErr = (error.number & 0xffff);
  63. if (1387 == nErr) // ERROR_NO_SUCH_MEMBER
  64. {
  65. // We get this when you try to create a user account with
  66. // login name == %computername%. The creation succeeds,
  67. // but adding the account to a group fails.
  68. // While still running, the account appears as a guest
  69. // account (it says "Guest account is active"), but after
  70. // restarting nusrmgr, the account doesn't appear. At that
  71. // point, if you try to "create" the account again, it
  72. // fails with "account already exists."
  73. // In lusrmgr.msc, the account appears, but is not a
  74. // member of any group (not Users, not Guests, nothing).
  75. // NTRAID#NTBUG9-201535-2000/10/11-jeffreys
  76. // NTRAID#NTBUG9-201538-2000/10/11-jeffreys
  77. // Delete the account.
  78. top.window.g_oUserList.remove(oNewUser.setting("LoginName"), null);
  79. // Tell the user
  80. alert(top.window.L_NameIsComputer_ErrorMessage);
  81. // Go back to the name page
  82. top.window.g_szNewName = szName;
  83. top.window.g_Navigator.back();
  84. }
  85. else
  86. {
  87. //alert("Error = " + nErr); // for debugging only
  88. throw error;
  89. }
  90. }
  91. if (0 == nErr)
  92. top.window.g_Navigator.navigate("mainpage2.htm", true);
  93. }
  94. }
  95. }