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.

242 lines
6.4 KiB

  1. #pragma once
  2. #include "Error.h"
  3. #include "Resource.h"
  4. #include "VarSetBase.h"
  5. //---------------------------------------------------------------------------
  6. // VarSet AccountOptions Class
  7. //---------------------------------------------------------------------------
  8. class CVarSetAccountOptions : public CVarSet
  9. {
  10. public:
  11. CVarSetAccountOptions(const CVarSet& rVarSet) :
  12. CVarSet(rVarSet)
  13. {
  14. // must specify that security translation uses the migrated objects
  15. // table for all cases except when using a sid mapping file
  16. Put(DCTVS_AccountOptions_SecurityInputMOT, true);
  17. }
  18. //
  19. void SetPasswordOption(long lOption, LPCTSTR pszDc = NULL)
  20. {
  21. Put(DCTVS_AccountOptions_GenerateStrongPasswords, (lOption != admtPasswordFromName));
  22. Put(DCTVS_AccountOptions_CopyPasswords, (lOption == admtCopyPassword));
  23. if (lOption == admtCopyPassword)
  24. {
  25. if (pszDc)
  26. {
  27. Put(DCTVS_AccountOptions_PasswordDC, pszDc);
  28. }
  29. else
  30. {
  31. AdmtThrowError(GUID_NULL, GUID_NULL, E_INVALIDARG, IDS_E_PASSWORD_DC_NOT_SPECIFIED);
  32. }
  33. }
  34. }
  35. void SetPasswordFile(LPCTSTR pszFile)
  36. {
  37. if (pszFile && (_tcslen(pszFile) > 0))
  38. {
  39. Put(DCTVS_AccountOptions_PasswordFile, pszFile);
  40. }
  41. else
  42. {
  43. Put(DCTVS_AccountOptions_PasswordFile, GetLogFolder() + _T("Passwords.txt"));
  44. }
  45. }
  46. void SetConflictOptions(long lOptions, LPCTSTR pszPrefixOrSuffix);
  47. void SetDisableOption(long lOption)
  48. {
  49. long lTarget = lOption & (admtDisableTarget|admtTargetSameAsSource);
  50. Put(DCTVS_AccountOptions_DisableCopiedAccounts, lTarget == admtDisableTarget);
  51. Put(DCTVS_AccountOptions_TgtStateSameAsSrc, lTarget == admtTargetSameAsSource);
  52. Put(DCTVS_AccountOptions_DisableSourceAccounts, (lOption & admtDisableSource) != 0);
  53. }
  54. void SetSourceExpiration(long lExpiration);
  55. // SetUserMigrationOptions is for user migration only
  56. void SetUserMigrationOptions(bool bMigrateGroups, bool bUpdateMigrated)
  57. {
  58. Put(DCTVS_AccountOptions_CopyUsers, true);
  59. Put(DCTVS_AccountOptions_CopyLocalGroups, bMigrateGroups);
  60. Put(DCTVS_AccountOptions_CopyMemberOf, bMigrateGroups);
  61. Put(DCTVS_AccountOptions_CopyComputers, false);
  62. Put(DCTVS_AccountOptions_CopyContainerContents, false);
  63. Put(DCTVS_AccountOptions_IncludeMigratedAccts, bMigrateGroups ? bUpdateMigrated : false);
  64. }
  65. // SetGroupMigrationOptions is for group migration only
  66. void SetGroupMigrationOptions(bool bMigrateMembers, bool bUpdateMigrated)
  67. {
  68. Put(DCTVS_AccountOptions_CopyUsers, bMigrateMembers);
  69. Put(DCTVS_AccountOptions_CopyLocalGroups, true);
  70. Put(DCTVS_AccountOptions_CopyComputers, false);
  71. Put(DCTVS_AccountOptions_CopyContainerContents, bMigrateMembers);
  72. Put(DCTVS_AccountOptions_CopyMemberOf, false);
  73. Put(DCTVS_AccountOptions_IncludeMigratedAccts, bMigrateMembers ? bUpdateMigrated : false);
  74. }
  75. // SetComputerMigrationOptions is for computer migration only
  76. void SetComputerMigrationOptions()
  77. {
  78. Put(DCTVS_AccountOptions_CopyUsers, false);
  79. Put(DCTVS_AccountOptions_CopyLocalGroups, false);
  80. Put(DCTVS_AccountOptions_CopyComputers, true);
  81. Put(DCTVS_AccountOptions_CopyContainerContents, false);
  82. Put(DCTVS_AccountOptions_CopyMemberOf, false);
  83. }
  84. // SetSecurityTranslationOptions is for security translation only
  85. void SetSecurityTranslationOptions()
  86. {
  87. Put(DCTVS_AccountOptions_CopyUsers, false);
  88. Put(DCTVS_AccountOptions_CopyLocalGroups, false);
  89. Put(DCTVS_AccountOptions_CopyComputers, false);
  90. Put(DCTVS_AccountOptions_CopyContainerContents, false);
  91. // Put(DCTVS_AccountOptions_CopyMemberOf, false);
  92. }
  93. void SetMigrateSids(bool bMigrate)
  94. {
  95. Put(DCTVS_AccountOptions_AddSidHistory, bMigrate);
  96. }
  97. void SetSidHistoryCredentials(LPCTSTR pszDomain, LPCTSTR pszUserName, LPCTSTR pszPassword)
  98. {
  99. Put(DCTVS_AccountOptions_SidHistoryCredentials_Domain, pszDomain);
  100. Put(DCTVS_AccountOptions_SidHistoryCredentials_UserName, pszUserName);
  101. Put(DCTVS_AccountOptions_SidHistoryCredentials_Password, pszPassword);
  102. }
  103. void SetFixGroupMembership(bool bFix)
  104. {
  105. Put(DCTVS_AccountOptions_FixMembership, bFix);
  106. }
  107. void SetUpdateUserRights(bool bUpdate)
  108. {
  109. Put(DCTVS_AccountOptions_UpdateUserRights, bUpdate);
  110. }
  111. void SetTranslateRoamingProfile(bool bTranslate)
  112. {
  113. Put(DCTVS_AccountOptions_TranslateRoamingProfiles, bTranslate);
  114. }
  115. void SetExcludedUserProps(LPCTSTR pszProperties)
  116. {
  117. if (pszProperties && (_tcslen(pszProperties) > 0))
  118. {
  119. Put(DCTVS_AccountOptions_ExcludeProps, true);
  120. Put(DCTVS_AccountOptions_ExcludedUserProps, pszProperties);
  121. }
  122. }
  123. void SetExcludedGroupProps(LPCTSTR pszProperties)
  124. {
  125. if (pszProperties && (_tcslen(pszProperties) > 0))
  126. {
  127. Put(DCTVS_AccountOptions_ExcludeProps, true);
  128. Put(DCTVS_AccountOptions_ExcludedGroupProps, pszProperties);
  129. }
  130. }
  131. void SetExcludedComputerProps(LPCTSTR pszProperties)
  132. {
  133. if (pszProperties && (_tcslen(pszProperties) > 0))
  134. {
  135. Put(DCTVS_AccountOptions_ExcludeProps, true);
  136. Put(DCTVS_AccountOptions_ExcludedComputerProps, pszProperties);
  137. }
  138. }
  139. void SetSecurityMapFile(LPCTSTR pszFile)
  140. {
  141. if (pszFile && (_tcslen(pszFile) > 0))
  142. {
  143. Put(DCTVS_AccountOptions_SecurityInputMOT, false);
  144. Put(DCTVS_AccountOptions_SecurityMapFile, pszFile);
  145. }
  146. }
  147. protected:
  148. void SetReplaceExistingAccounts(bool bReplace)
  149. {
  150. Put(DCTVS_AccountOptions_ReplaceExistingAccounts, bReplace);
  151. }
  152. void SetRemoveExistingUserRights(bool bRemove)
  153. {
  154. Put(DCTVS_AccountOptions_RemoveExistingUserRights, bRemove);
  155. }
  156. void SetReplaceExistingGroupMembers(bool bReplace)
  157. {
  158. Put(DCTVS_AccountOptions_ReplaceExistingGroupMembers, bReplace);
  159. }
  160. void SetMoveReplacedAccounts(bool bMove)
  161. {
  162. Put(DCTVS_AccountOptions_MoveReplacedAccounts, bMove);
  163. }
  164. void SetPrefix(LPCTSTR pszPrefix)
  165. {
  166. Put(DCTVS_AccountOptions_Prefix, pszPrefix);
  167. }
  168. void SetSuffix(LPCTSTR pszSuffix)
  169. {
  170. Put(DCTVS_AccountOptions_Suffix, pszSuffix);
  171. }
  172. };
  173. //---------------------------------------------------------------------------
  174. // Validation Functions
  175. //---------------------------------------------------------------------------
  176. inline bool IsDisableOptionValid(long lOption)
  177. {
  178. bool bIs = false;
  179. // if only valid option bits are set...
  180. if (!(lOption & ~(admtEnableTarget|admtDisableSource|admtDisableTarget|admtTargetSameAsSource)))
  181. {
  182. // and not both disable target and target same as source options...
  183. if (!((lOption & admtDisableTarget) && (lOption & admtTargetSameAsSource)))
  184. {
  185. // then valid
  186. bIs = true;
  187. }
  188. }
  189. return bIs;
  190. }
  191. inline bool IsSourceExpirationValid(long lExpiration)
  192. {
  193. return ((lExpiration == -1) || ((lExpiration >= 0) && (lExpiration <= 1095)));
  194. }