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.

179 lines
7.5 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 2000 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: Policy.cpp
  6. //
  7. // Project: Windows 2000 IAS
  8. //
  9. // Description: Implementation of the CPolicy class
  10. //
  11. // Author: tperraut
  12. //
  13. // Revision 02/24/2000 created
  14. //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #include "stdafx.h"
  17. #include "Policy.h"
  18. //////////////////////////////////////////////////////////////////////////////
  19. // AddmsManipulationRules
  20. //////////////////////////////////////////////////////////////////////////////
  21. void CPolicy::SetmsManipulationRules(
  22. const _bstr_t& Search,
  23. const _bstr_t& Replace
  24. )
  25. {
  26. m_Search = Search;
  27. m_Replace = Replace;
  28. }
  29. //////////////////////////////////////////////////////////////////////////////
  30. // Persist
  31. // return the Identity of the new profile
  32. //////////////////////////////////////////////////////////////////////////////
  33. LONG CPolicy::Persist(CGlobalData& GlobalData)
  34. {
  35. const LONG MAX_LONG = 14;
  36. // Get the proxy policy and proxyprofiles containers
  37. const WCHAR ProxyPoliciesPath[] =
  38. L"Root\0"
  39. L"Microsoft Internet Authentication Service\0"
  40. L"Proxy Policies\0";
  41. LONG ProxyPolicyIdentity;
  42. GlobalData.m_pObjects->WalkPath(ProxyPoliciesPath, ProxyPolicyIdentity);
  43. const WCHAR ProxyProfilesPath[] =
  44. L"Root\0"
  45. L"Microsoft Internet Authentication Service\0"
  46. L"Proxy Profiles\0";
  47. LONG ProxyProfileIdentity;
  48. GlobalData.m_pObjects->WalkPath(ProxyProfilesPath, ProxyProfileIdentity);
  49. // Create a new policy
  50. GlobalData.m_pObjects->InsertObject(
  51. m_PolicyName,
  52. ProxyPolicyIdentity,
  53. m_NewPolicyIdentity
  54. );
  55. // create a new profile
  56. GlobalData.m_pObjects->InsertObject(
  57. m_PolicyName,
  58. ProxyProfileIdentity,
  59. m_NewProfileIdentity
  60. );
  61. m_Persisted = TRUE;
  62. // Now insert the attributes in the policy and in the profile
  63. const _bstr_t msNPAction = L"msNPAction";
  64. GlobalData.m_pProperties->InsertProperty(
  65. m_NewPolicyIdentity,
  66. msNPAction,
  67. VT_BSTR,
  68. m_PolicyName
  69. );
  70. const _bstr_t msNPConstraint = L"msNPConstraint";
  71. GlobalData.m_pProperties->InsertProperty(
  72. m_NewPolicyIdentity,
  73. msNPConstraint,
  74. VT_BSTR,
  75. m_Constraint
  76. );
  77. const _bstr_t msNPSequence = L"msNPSequence";
  78. WCHAR TempString[MAX_LONG];
  79. _bstr_t Seq = _ltow(m_Sequence, TempString, 10);
  80. GlobalData.m_pProperties->InsertProperty(
  81. m_NewPolicyIdentity,
  82. msNPSequence,
  83. VT_I4,
  84. Seq
  85. );
  86. const _bstr_t msAuthProviderType = L"msAuthProviderType";
  87. _bstr_t Provider = _ltow(m_AuthType, TempString, 10);
  88. GlobalData.m_pProperties->InsertProperty(
  89. m_NewProfileIdentity,
  90. msAuthProviderType,
  91. VT_I4,
  92. Provider
  93. );
  94. if ( m_ServerGroup.length() )
  95. {
  96. const _bstr_t msAuthProviderName = L"msAuthProviderName";
  97. GlobalData.m_pProperties->InsertProperty(
  98. m_NewProfileIdentity,
  99. msAuthProviderName,
  100. VT_BSTR,
  101. m_ServerGroup
  102. );
  103. }
  104. // If there's an Accounting provider, then its name should
  105. // be persisted too
  106. if ( m_AcctType )
  107. {
  108. const _bstr_t msAcctProviderType = L"msAcctProviderType";
  109. Provider = _ltow(m_AuthType, TempString, 10);
  110. GlobalData.m_pProperties->InsertProperty(
  111. m_NewProfileIdentity,
  112. msAcctProviderType,
  113. VT_I4,
  114. Provider
  115. );
  116. const _bstr_t msAcctProviderName = L"msAcctProviderName";
  117. GlobalData.m_pProperties->InsertProperty(
  118. m_NewProfileIdentity,
  119. msAcctProviderName,
  120. VT_BSTR,
  121. m_ServerGroup
  122. );
  123. }
  124. // persist the seearch / replace rules only if there's a search rule
  125. if ( m_Search.length() )
  126. {
  127. const _bstr_t msManipulationRule = L"msManipulationRule";
  128. GlobalData.m_pProperties->InsertProperty(
  129. m_NewProfileIdentity,
  130. msManipulationRule,
  131. VT_BSTR,
  132. m_Search
  133. );
  134. // make sure that InsertProperty has some valid parameters
  135. if ( ! m_Replace.length() )
  136. {
  137. m_Replace = L"";
  138. }
  139. GlobalData.m_pProperties->InsertProperty(
  140. m_NewProfileIdentity,
  141. msManipulationRule,
  142. VT_BSTR,
  143. m_Replace
  144. );
  145. }
  146. // Sets the validation target
  147. if ( m_ManipulationTarget )
  148. {
  149. const _bstr_t msManipulationTarget = L"msManipulationTarget";
  150. _bstr_t Target = _ltow(m_ManipulationTarget, TempString, 10);
  151. GlobalData.m_pProperties->InsertProperty(
  152. m_NewProfileIdentity,
  153. msManipulationTarget,
  154. VT_I4,
  155. Target
  156. );
  157. }
  158. return m_NewProfileIdentity;
  159. }