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.

239 lines
11 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. SceProfInfoAdapter.cpp
  5. Abstract:
  6. Implementation for class SceProfInfoAdapter
  7. This is an adapter for structure SCE_PROFILE_INFO. This class is
  8. necessary becaue SCE_PROFILE_INFO is defined differently in
  9. w2k and in xp and provides a common structure to work with regardless
  10. of whether the system is winxp or win2k
  11. This class is given a pointer to an SCE_PROFILE_INFO structure
  12. at construct time and its fields are populated accordingly depending
  13. on which OS the dll is running on.
  14. Author:
  15. Steven Chan (t-schan) July 2002
  16. --*/
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <windows.h>
  21. #include <iostream.h>
  22. #include "SceProfInfoAdapter.h"
  23. #include "SceLogException.h"
  24. SceProfInfoAdapter::SceProfInfoAdapter(
  25. PSCE_PROFILE_INFO ppInfo,
  26. BOOL bIsW2k
  27. )
  28. /*++
  29. Routine Description:
  30. constructor for a new SceProfInfoAdapter
  31. casts the ppInfo argument appropriately depending on whether
  32. OS is win2k or winxp and copies the data to its own fields so that
  33. user can access one single structure regardless of whether the OS
  34. is win2k or winxp
  35. Arguments:
  36. ppInfo: SCE_PROFILE_INFO to be adapted
  37. bIsW2k: true if running on win2k else false
  38. Return Value:
  39. none
  40. --*/
  41. {
  42. try {
  43. if (bIsW2k) {
  44. this->Type = ((PW2K_SCE_PROFILE_INFO) ppInfo)->Type;
  45. this->MinimumPasswordAge = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MinimumPasswordAge;
  46. this->MaximumPasswordAge = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MaximumPasswordAge;
  47. this->MinimumPasswordLength = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MinimumPasswordLength;
  48. this->PasswordComplexity = ((PW2K_SCE_PROFILE_INFO) ppInfo)->PasswordComplexity;
  49. this->PasswordHistorySize = ((PW2K_SCE_PROFILE_INFO) ppInfo)->PasswordHistorySize;
  50. this->LockoutBadCount = ((PW2K_SCE_PROFILE_INFO) ppInfo)->LockoutBadCount;
  51. this->ResetLockoutCount = ((PW2K_SCE_PROFILE_INFO) ppInfo)->ResetLockoutCount;
  52. this->LockoutDuration = ((PW2K_SCE_PROFILE_INFO) ppInfo)->LockoutDuration;
  53. this->RequireLogonToChangePassword = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RequireLogonToChangePassword;
  54. this->ForceLogoffWhenHourExpire = ((PW2K_SCE_PROFILE_INFO) ppInfo)->ForceLogoffWhenHourExpire;
  55. this->NewAdministratorName = ((PW2K_SCE_PROFILE_INFO) ppInfo)->NewAdministratorName;
  56. this->NewGuestName = ((PW2K_SCE_PROFILE_INFO) ppInfo)->NewGuestName;
  57. this->SecureSystemPartition = ((PW2K_SCE_PROFILE_INFO) ppInfo)->SecureSystemPartition;
  58. this->ClearTextPassword = ((PW2K_SCE_PROFILE_INFO) ppInfo)->ClearTextPassword;
  59. this->LSAAnonymousNameLookup = SCE_NO_VALUE;
  60. if (((SCETYPE) W2K_SCE_ENGINE_SAP)==ppInfo->Type) {
  61. this->pUserList = ((PW2K_SCE_PROFILE_INFO) ppInfo)->OtherInfo.sap.pUserList;
  62. } else if (((SCETYPE) W2K_SCE_ENGINE_SMP)==ppInfo->Type) {
  63. this->pUserList = ((PW2K_SCE_PROFILE_INFO) ppInfo)->OtherInfo.smp.pUserList;
  64. } else {
  65. this->pUserList = NULL;
  66. }
  67. if (((SCETYPE) W2K_SCE_ENGINE_SAP)==ppInfo->Type) {
  68. this->pPrivilegeAssignedTo = ((PW2K_SCE_PROFILE_INFO) ppInfo)->OtherInfo.sap.pPrivilegeAssignedTo;
  69. } else if (((SCETYPE) W2K_SCE_ENGINE_SMP)==ppInfo->Type) {
  70. this->pPrivilegeAssignedTo = ((PW2K_SCE_PROFILE_INFO) ppInfo)->OtherInfo.smp.pPrivilegeAssignedTo;
  71. } else {
  72. this->pPrivilegeAssignedTo = NULL;
  73. }
  74. this->pGroupMembership = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pGroupMembership;
  75. this->pRegistryKeys = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pRegistryKeys;
  76. this->pServices = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pServices;
  77. this->pFiles = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pFiles;
  78. this->pDsObjects = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pDsObjects;
  79. this->pKerberosInfo = ((PW2K_SCE_PROFILE_INFO) ppInfo)->pKerberosInfo;
  80. this->MaximumLogSize[0] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MaximumLogSize[0];
  81. this->MaximumLogSize[1] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MaximumLogSize[1];
  82. this->MaximumLogSize[2] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->MaximumLogSize[2];
  83. this->AuditLogRetentionPeriod[0] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditLogRetentionPeriod[0];
  84. this->AuditLogRetentionPeriod[1] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditLogRetentionPeriod[1];
  85. this->AuditLogRetentionPeriod[2] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditLogRetentionPeriod[2];
  86. this->RetentionDays[0] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RetentionDays[0];
  87. this->RetentionDays[1] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RetentionDays[1];
  88. this->RetentionDays[2] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RetentionDays[2];
  89. this->RestrictGuestAccess[0] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RestrictGuestAccess[0];
  90. this->RestrictGuestAccess[1] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RestrictGuestAccess[1];
  91. this->RestrictGuestAccess[2] = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RestrictGuestAccess[2];
  92. this->AuditSystemEvents = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditSystemEvents;
  93. this->AuditLogonEvents = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditLogonEvents;
  94. this->AuditObjectAccess = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditObjectAccess;
  95. this->AuditPrivilegeUse = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditPrivilegeUse;
  96. this->AuditPolicyChange = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditPolicyChange;
  97. this->AuditAccountManage = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditAccountManage;
  98. this->AuditProcessTracking = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditProcessTracking;
  99. this->AuditDSAccess = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditDSAccess;
  100. this->AuditAccountLogon = ((PW2K_SCE_PROFILE_INFO) ppInfo)->AuditAccountLogon;
  101. this->CrashOnAuditFull = ((PW2K_SCE_PROFILE_INFO) ppInfo)->CrashOnAuditFull;
  102. this->RegValueCount = ((PW2K_SCE_PROFILE_INFO) ppInfo)->RegValueCount;
  103. this->aRegValues = ((PW2K_SCE_PROFILE_INFO) ppInfo)->aRegValues;
  104. this->EnableAdminAccount = SCE_NO_VALUE;
  105. this->EnableGuestAccount = SCE_NO_VALUE;
  106. } else {
  107. this->Type = ppInfo->Type;
  108. this->MinimumPasswordAge = ppInfo->MinimumPasswordAge;
  109. this->MaximumPasswordAge = ppInfo->MaximumPasswordAge;
  110. this->MinimumPasswordLength = ppInfo->MinimumPasswordLength;
  111. this->PasswordComplexity = ppInfo->PasswordComplexity;
  112. this->PasswordHistorySize = ppInfo->PasswordHistorySize;
  113. this->LockoutBadCount = ppInfo->LockoutBadCount;
  114. this->ResetLockoutCount = ppInfo->ResetLockoutCount;
  115. this->LockoutDuration = ppInfo->LockoutDuration;
  116. this->RequireLogonToChangePassword = ppInfo->RequireLogonToChangePassword;
  117. this->ForceLogoffWhenHourExpire = ppInfo->ForceLogoffWhenHourExpire;
  118. this->NewAdministratorName = ppInfo->NewAdministratorName;
  119. this->NewGuestName = ppInfo->NewGuestName;
  120. this->SecureSystemPartition = ppInfo->SecureSystemPartition;
  121. this->ClearTextPassword = ppInfo->ClearTextPassword;
  122. this->LSAAnonymousNameLookup = ppInfo->LSAAnonymousNameLookup;
  123. if (SCE_ENGINE_SAP == ppInfo->Type) {
  124. this->pUserList = ppInfo->OtherInfo.sap.pUserList;
  125. } else if (SCE_ENGINE_SMP == ppInfo->Type) {
  126. this->pUserList = ppInfo->OtherInfo.smp.pUserList;
  127. } else {
  128. this->pUserList = NULL;
  129. }
  130. if (SCE_ENGINE_SAP == ppInfo->Type) {
  131. this->pPrivilegeAssignedTo = ppInfo->OtherInfo.sap.pPrivilegeAssignedTo;
  132. } else if (SCE_ENGINE_SMP == ppInfo->Type) {
  133. this->pPrivilegeAssignedTo = ppInfo->OtherInfo.smp.pPrivilegeAssignedTo;
  134. } else {
  135. this->pPrivilegeAssignedTo = NULL;
  136. }
  137. this->pGroupMembership = ppInfo->pGroupMembership;
  138. this->pRegistryKeys = ppInfo->pRegistryKeys;
  139. this->pServices = ppInfo->pServices;
  140. this->pFiles = ppInfo->pFiles;
  141. this->pDsObjects = ppInfo->pDsObjects;
  142. this->pKerberosInfo = ppInfo->pKerberosInfo;
  143. this->MaximumLogSize[0] = ppInfo->MaximumLogSize[0];
  144. this->MaximumLogSize[1] = ppInfo->MaximumLogSize[1];
  145. this->MaximumLogSize[2] = ppInfo->MaximumLogSize[2];
  146. this->AuditLogRetentionPeriod[0] = ppInfo->AuditLogRetentionPeriod[0];
  147. this->AuditLogRetentionPeriod[1] = ppInfo->AuditLogRetentionPeriod[1];
  148. this->AuditLogRetentionPeriod[2] = ppInfo->AuditLogRetentionPeriod[2];
  149. this->RetentionDays[0] = ppInfo->RetentionDays[0];
  150. this->RetentionDays[1] = ppInfo->RetentionDays[1];
  151. this->RetentionDays[2] = ppInfo->RetentionDays[2];
  152. this->RestrictGuestAccess[0] = ppInfo->RestrictGuestAccess[0];
  153. this->RestrictGuestAccess[1] = ppInfo->RestrictGuestAccess[1];
  154. this->RestrictGuestAccess[2] = ppInfo->RestrictGuestAccess[2];
  155. this->AuditSystemEvents = ppInfo->AuditSystemEvents;
  156. this->AuditLogonEvents = ppInfo->AuditLogonEvents;
  157. this->AuditObjectAccess = ppInfo->AuditObjectAccess;
  158. this->AuditPrivilegeUse = ppInfo->AuditPrivilegeUse;
  159. this->AuditPolicyChange = ppInfo->AuditPolicyChange;
  160. this->AuditAccountManage = ppInfo->AuditAccountManage;
  161. this->AuditProcessTracking = ppInfo->AuditProcessTracking;
  162. this->AuditDSAccess = ppInfo->AuditDSAccess;
  163. this->AuditAccountLogon = ppInfo->AuditAccountLogon;
  164. this->CrashOnAuditFull = ppInfo->CrashOnAuditFull;
  165. this->RegValueCount = ppInfo->RegValueCount;
  166. this->aRegValues = ppInfo->aRegValues;
  167. this->EnableAdminAccount = ppInfo->EnableAdminAccount;
  168. this->EnableGuestAccount = ppInfo->EnableGuestAccount;
  169. }
  170. } catch (...) {
  171. throw new SceLogException(SceLogException::SXERROR_READ,
  172. L"SceProfInfoAdapter::SceProfInfoAdapter(ppInfo, bIsW2k)",
  173. NULL,
  174. 0);
  175. }
  176. }
  177. SceProfInfoAdapter::~SceProfInfoAdapter(
  178. )
  179. /*++
  180. Routine Description:
  181. SceProfInfoAdapter destructor
  182. Arguments:
  183. none
  184. Return Value:
  185. none
  186. --*/
  187. {
  188. }