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.

203 lines
7.1 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // @doc
  4. //
  5. // @module CProfile.h | Declaration of the CProfile class.
  6. //
  7. // Author: Darren Anderson
  8. //
  9. // Date: 4/26/00
  10. //
  11. // Copyright <cp> 1999-2000 Microsoft Corporation. All Rights Reserved.
  12. //
  13. //-----------------------------------------------------------------------------
  14. #pragma once
  15. #include "ppstorage.h"
  16. //-----------------------------------------------------------------------------
  17. //
  18. // @class CProfile | This class abstracts out a number of common profile
  19. // operations.
  20. //
  21. //-----------------------------------------------------------------------------
  22. class CUserProfileBase;
  23. class CProfile
  24. {
  25. public:
  26. static const UINT AllMembers = (UINT)(-1);
  27. // @access Protected members
  28. protected:
  29. // @cmember <md CProfile::m_bInitialized> is true if this instance has been
  30. // initialized with a profile string.
  31. bool m_bInitialized;
  32. // @cmember <md CProfile::m_piProfile> is used to perform ticket operations.
  33. CComPtr<IPassportProfile> m_piProfile;
  34. // @cmember Pointer to global handler base.
  35. CPassportHandlerBase* m_pHandler;
  36. // @cmember Helper function to create <md CProfile::m_piProfile>.
  37. void CreateProfileObject(void);
  38. // @cmember Create a test mode (i.e. site id 1) cookie.
  39. static void MakeTest(LPCWSTR szMemberName,
  40. ULONG ulIdLow,
  41. ULONG ulIdHigh,
  42. ULONG ulProfileVersion,
  43. USHORT nKeyVersion,
  44. CStringW& cszProfileCookie,
  45. UINT cEle
  46. );
  47. // @cmember Create a limited consent cookie.
  48. static HRESULT MakeLimited(
  49. LPCWSTR szMemberName,
  50. ULONG ulIdlow,
  51. ULONG ulIdHigh,
  52. ULONG ulProfileVersion,
  53. PASSPORT_PROFILE_BDAYPRECISION nBDayPrecision,
  54. DATE dtCookieBirthdate,
  55. ULONG ulFlags,
  56. ULONG ulSiteId,
  57. USHORT nKeyVersion,
  58. bool bSecure,
  59. CStringW& cszProfileCookie,
  60. UINT cEle
  61. );
  62. // @cmember Create a limited consent cookie.
  63. static HRESULT MakeLimited(
  64. LPCWSTR szMemberName,
  65. ULONG ulIdlow,
  66. ULONG ulIdHigh,
  67. ULONG ulProfileVersion,
  68. PASSPORT_PROFILE_BDAYPRECISION nBDayPrecision,
  69. DATE dtCookieBirthdate,
  70. ULONG ulFlags,
  71. ULONG ulSiteId,
  72. USHORT nKeyVersion,
  73. CStringW& cszProfileCookie,
  74. UINT cEle
  75. );
  76. // @access Public members
  77. public:
  78. //
  79. // Note, two-phase construction. Constructor followed
  80. // by PutProfile.
  81. //
  82. // @cmember Constructor.
  83. CProfile();
  84. // @cmember Destructor.
  85. ~CProfile();
  86. // @cmember Initialize this instance with a profile cookie string.
  87. void PutProfile(LPCWSTR szProfile);
  88. // @cmember Has this instance been initialized?
  89. bool IsInitialized(void);
  90. // @cmember Does this instance contain a valid profile?
  91. bool IsValid(void);
  92. //
  93. // Multiple Get's for different types.
  94. //
  95. // @cmember Get string-type attribute.
  96. void Get(PASSPORT_PROFILE_ITEM item, CStringW& cszValue);
  97. // @cmember Get string-type attribute, but return as BSTR.
  98. void Get(PASSPORT_PROFILE_ITEM item, CComBSTR& cszValue);
  99. // @cmember Get a ULONG-type attribute.
  100. void Get(PASSPORT_PROFILE_ITEM item, ULONG& ulValue);
  101. // @cmember Get a DATE-type attribute.
  102. void Get(PASSPORT_PROFILE_ITEM item, DATE& dtValue);
  103. // @cmember Get a USHORT-type attribute.
  104. void Get(PASSPORT_PROFILE_ITEM item, USHORT& usValue);
  105. //
  106. // Membername/domain methods.
  107. //
  108. // @cmember Retrieve the domain portion of the current user's name.
  109. HRESULT DomainFromMemberName(CStringW& cszDomain);
  110. // @cmember Retrieve the alias portion of the current user's name.
  111. HRESULT AliasFromMemberName(CStringW& cszAlias);
  112. // @cmember Retrieve the display version of the current user's naem.
  113. HRESULT FullDisplayMemberName(CStringW& cszMemberName);
  114. //
  115. // Profile cookie manipulation functions.
  116. //
  117. //todo change this later -- make sure to implement kids consent correct!!
  118. static HRESULT Make(
  119. CUserProfileBase * cdbCoreProfile,
  120. LPCWSTR szMemberName,
  121. ULONG nSiteId,
  122. USHORT nKeyVersion,
  123. KPP nKPP,
  124. LPCWSTR szKPPVC,
  125. bool bMD5Silent,
  126. CStringW& cszProfileCookie,
  127. ULONG &ulKidsFlags,
  128. UINT cEle
  129. );
  130. // @cmember Create a profile cookie string using the parameters passed in.
  131. static HRESULT Make(
  132. CPPCoreProfileStorage& profile,
  133. LPCWSTR szMemberName,
  134. ULONG nSiteId,
  135. USHORT nKeyVersion,
  136. KPP nKPP,
  137. LPCWSTR szKPPVC,
  138. bool bSecure,
  139. bool bMD5Silent,
  140. CStringW& cszProfileCookie,
  141. ULONG &ulKidsFlags,
  142. UINT cEle
  143. );
  144. HRESULT MD5Make(ULONG nSiteId,
  145. USHORT nKeyVersion,
  146. UINT cEle,
  147. CStringW& cszProfileCookie
  148. );
  149. // @cmember Create a copy of the current profile cookie using the
  150. // information passed in.
  151. HRESULT Copy(ULONG nSiteId,
  152. USHORT nKeyVersion,
  153. KPP nKPP,
  154. LPCWSTR szKPPVC,
  155. bool bSecure,
  156. bool bNewReg,
  157. CStringW& cszProfileCookie,
  158. ULONG &ulKidsFlags,
  159. UINT cEles,
  160. bool bMD5Silent = false, // TODO: should remove default
  161. LPCWSTR szMemberName = NULL);
  162. // @cmember Add the cookie specified to the response.
  163. static HRESULT Set(LPCWSTR szProfileCookie,
  164. bool bPersist);
  165. // @cmember Expire the current profile cookie.
  166. static HRESULT Expire(void);
  167. };
  168. // EOF