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.

244 lines
6.6 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, GetLogsFolder() + _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 SetFixGroupMembership(bool bFix)
  98. {
  99. Put(DCTVS_AccountOptions_FixMembership, bFix);
  100. }
  101. void SetUpdateUserRights(bool bUpdate)
  102. {
  103. Put(DCTVS_AccountOptions_UpdateUserRights, bUpdate);
  104. }
  105. void SetTranslateRoamingProfile(bool bTranslate)
  106. {
  107. Put(DCTVS_AccountOptions_TranslateRoamingProfiles, bTranslate);
  108. }
  109. void SetExcludedUserProps(LPCTSTR pszProperties)
  110. {
  111. if (pszProperties && (_tcslen(pszProperties) > 0))
  112. {
  113. Put(DCTVS_AccountOptions_ExcludeProps, true);
  114. Put(DCTVS_AccountOptions_ExcludedUserProps, pszProperties);
  115. }
  116. }
  117. void SetExcludedInetOrgPersonProps(LPCTSTR pszProperties)
  118. {
  119. if (pszProperties && (_tcslen(pszProperties) > 0))
  120. {
  121. Put(DCTVS_AccountOptions_ExcludeProps, true);
  122. Put(DCTVS_AccountOptions_ExcludedInetOrgPersonProps, pszProperties);
  123. }
  124. }
  125. void SetExcludedGroupProps(LPCTSTR pszProperties)
  126. {
  127. if (pszProperties && (_tcslen(pszProperties) > 0))
  128. {
  129. Put(DCTVS_AccountOptions_ExcludeProps, true);
  130. Put(DCTVS_AccountOptions_ExcludedGroupProps, pszProperties);
  131. }
  132. }
  133. void SetExcludedComputerProps(LPCTSTR pszProperties)
  134. {
  135. if (pszProperties && (_tcslen(pszProperties) > 0))
  136. {
  137. Put(DCTVS_AccountOptions_ExcludeProps, true);
  138. Put(DCTVS_AccountOptions_ExcludedComputerProps, pszProperties);
  139. }
  140. }
  141. void SetSecurityMapFile(LPCTSTR pszFile)
  142. {
  143. if (pszFile && (_tcslen(pszFile) > 0))
  144. {
  145. Put(DCTVS_AccountOptions_SecurityInputMOT, false);
  146. Put(DCTVS_AccountOptions_SecurityMapFile, pszFile);
  147. }
  148. }
  149. protected:
  150. void SetReplaceExistingAccounts(bool bReplace)
  151. {
  152. Put(DCTVS_AccountOptions_ReplaceExistingAccounts, bReplace);
  153. }
  154. void SetRemoveExistingUserRights(bool bRemove)
  155. {
  156. Put(DCTVS_AccountOptions_RemoveExistingUserRights, bRemove);
  157. }
  158. void SetReplaceExistingGroupMembers(bool bReplace)
  159. {
  160. Put(DCTVS_AccountOptions_ReplaceExistingGroupMembers, bReplace);
  161. }
  162. void SetMoveReplacedAccounts(bool bMove)
  163. {
  164. Put(DCTVS_AccountOptions_MoveReplacedAccounts, bMove);
  165. }
  166. void SetPrefix(LPCTSTR pszPrefix)
  167. {
  168. Put(DCTVS_AccountOptions_Prefix, pszPrefix);
  169. }
  170. void SetSuffix(LPCTSTR pszSuffix)
  171. {
  172. Put(DCTVS_AccountOptions_Suffix, pszSuffix);
  173. }
  174. };
  175. //---------------------------------------------------------------------------
  176. // Validation Functions
  177. //---------------------------------------------------------------------------
  178. inline bool IsDisableOptionValid(long lOption)
  179. {
  180. bool bIs = false;
  181. // if only valid option bits are set...
  182. if (!(lOption & ~(admtEnableTarget|admtDisableSource|admtDisableTarget|admtTargetSameAsSource)))
  183. {
  184. // and not both disable target and target same as source options...
  185. if (!((lOption & admtDisableTarget) && (lOption & admtTargetSameAsSource)))
  186. {
  187. // then valid
  188. bIs = true;
  189. }
  190. }
  191. return bIs;
  192. }
  193. inline bool IsSourceExpirationValid(long lExpiration)
  194. {
  195. return ((lExpiration == -1) || ((lExpiration >= 0) && (lExpiration <= 1095)));
  196. }