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.

98 lines
2.4 KiB

  1. #include "StdAfx.h"
  2. #include "ADMTScript.h"
  3. #include "VarSetAccountOptions.h"
  4. #include <Validation.h>
  5. //---------------------------------------------------------------------------
  6. // VarSet Account Options Class
  7. //---------------------------------------------------------------------------
  8. // SetConflictOptions Method
  9. void CVarSetAccountOptions::SetConflictOptions(long lOptions, LPCTSTR pszPrefixOrSuffix)
  10. {
  11. long lOption = lOptions & 0x0F;
  12. long lFlags = lOptions & 0xF0;
  13. _bstr_t c_bstrEmpty;
  14. switch (lOption)
  15. {
  16. case admtRenameConflictingWithSuffix:
  17. {
  18. if (pszPrefixOrSuffix && (_tcslen(pszPrefixOrSuffix) > 0))
  19. {
  20. if (IsValidPrefixOrSuffix(pszPrefixOrSuffix))
  21. {
  22. SetReplaceExistingAccounts(false);
  23. SetPrefix(c_bstrEmpty);
  24. SetSuffix(pszPrefixOrSuffix);
  25. }
  26. else
  27. {
  28. AdmtThrowError(GUID_NULL, GUID_NULL, E_INVALIDARG, IDS_E_INVALID_CONFLICT_PREFIX_SUFFIX);
  29. }
  30. }
  31. else
  32. {
  33. AdmtThrowError(GUID_NULL, GUID_NULL, E_INVALIDARG, IDS_E_NO_CONFLICT_PREFIX);
  34. }
  35. break;
  36. }
  37. case admtRenameConflictingWithPrefix:
  38. {
  39. if (pszPrefixOrSuffix && (_tcslen(pszPrefixOrSuffix) > 0))
  40. {
  41. if (IsValidPrefixOrSuffix(pszPrefixOrSuffix))
  42. {
  43. SetReplaceExistingAccounts(false);
  44. SetPrefix(pszPrefixOrSuffix);
  45. SetSuffix(c_bstrEmpty);
  46. }
  47. else
  48. {
  49. AdmtThrowError(GUID_NULL, GUID_NULL, E_INVALIDARG, IDS_E_INVALID_CONFLICT_PREFIX_SUFFIX);
  50. }
  51. }
  52. else
  53. {
  54. AdmtThrowError(GUID_NULL, GUID_NULL, E_INVALIDARG, IDS_E_NO_CONFLICT_SUFFIX);
  55. }
  56. break;
  57. }
  58. case admtReplaceConflicting:
  59. {
  60. SetReplaceExistingAccounts(true);
  61. SetRemoveExistingUserRights((lFlags & admtRemoveExistingUserRights) ? true : false);
  62. SetReplaceExistingGroupMembers((lFlags & admtRemoveExistingMembers) ? true : false);
  63. SetMoveReplacedAccounts((lFlags & admtMoveReplacedAccounts) ? true : false);
  64. SetPrefix(c_bstrEmpty);
  65. SetSuffix(c_bstrEmpty);
  66. break;
  67. }
  68. default: // admtIgnoreConflicting
  69. {
  70. SetReplaceExistingAccounts(false);
  71. SetPrefix(c_bstrEmpty);
  72. SetSuffix(c_bstrEmpty);
  73. break;
  74. }
  75. }
  76. }
  77. // SetSourceExpiration Method
  78. void CVarSetAccountOptions::SetSourceExpiration(long lExpiration)
  79. {
  80. _variant_t vntExpiration;
  81. if (lExpiration >= 0)
  82. {
  83. vntExpiration = lExpiration;
  84. }
  85. Put(DCTVS_AccountOptions_ExpireSourceAccounts, vntExpiration);
  86. }