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.

350 lines
12 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: sdo.h
  6. //
  7. // Project: Everest
  8. //
  9. // Description: IAS Server Data Object Declaration
  10. //
  11. // Author: TLP 1/23/98
  12. //
  13. // When Who What
  14. // ---- --- ----
  15. // 2/28/98 TLP Prepare for IDataStore2
  16. // 8/24/98 SEB MS-CHAP handler moved to NTSamAuthentication.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////
  19. #ifndef __IAS_SDO_H_
  20. #define __IAS_SDO_H_
  21. #include "resource.h"
  22. #include <iascomp.h>
  23. #include <comdef.h>
  24. #include <sdoiaspriv.h>
  25. #include <datastore2.h>
  26. #include "sdoproperty.h"
  27. #include <map>
  28. #include <vector>
  29. #include <string>
  30. using namespace std;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Enumeration class definition
  33. /////////////////////////////////////////////////////////////////////////////
  34. typedef CComEnum< IEnumVARIANT,
  35. &__uuidof(IEnumVARIANT),
  36. VARIANT,
  37. _Copy<VARIANT>,
  38. CComSingleThreadModel
  39. > EnumVARIANT;
  40. //////////////////////////
  41. // Tracing Flags
  42. /////////////////////////
  43. // #define SDO_TRACE_VERBOSE
  44. #ifdef SDO_TRACE_VERBOSE
  45. #define SDO_TRACE_VERBOSE_0(msg) IASTracePrintf(msg)
  46. #define SDO_TRACE_VERBOSE_1(msg,param1) IASTracePrintf(msg,param1)
  47. #define SDO_TRACE_VERBOSE_2(msg,param1,param2) IASTracePrintf(msg,param1,param2)
  48. #define SDO_TRACE_VERBOSE_3(msg,param1,param2,param3) IASTracePrintf(msg,param1,param2,param3)
  49. #else
  50. #define SDO_TRACE_VERBOSE_0(msg)
  51. #define SDO_TRACE_VERBOSE_1(msg,param1)
  52. #define SDO_TRACE_VERBOSE_2(msg,param1,param2)
  53. #define SDO_TRACE_VERBOSE_3(msg,param1,param2,param3)
  54. #endif
  55. //////////////////////////////////////
  56. // IAS Policy Registry Key
  57. #define IAS_POLICY_REG_KEY L"SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Policy"
  58. /////////////////////////////////////////////////
  59. // Well - Known names of data store entities
  60. #define SDO_STOCK_PROPERTY_CLASS L"class"
  61. #define SDO_STOCK_PROPERTY_NAME L"name"
  62. #define SDO_STOCK_PROPERTY_CLASS_ID L"Component Prog Id"
  63. /////////////////////////////////////////////
  64. // IAS Service Data Store Type Registry Value
  65. #define IAS_DATASTORE_TYPE L"DataStoreType"
  66. //////////////////////////////
  67. // Data Store Object Names
  68. //
  69. #define DS_OBJECT_CLIENTS L"Clients"
  70. #define DS_OBJECT_SERVICE L"Microsoft Internet Authentication Service"
  71. #define DS_OBJECT_PROFILES L"RadiusProfiles"
  72. #define DS_OBJECT_POLICIES L"NetworkPolicy"
  73. #define DS_OBJECT_PROTOCOLS L"Protocols"
  74. #define DS_OBJECT_AUDITORS L"Auditors"
  75. #define DS_OBJECT_REQUESTHANDLERS L"RequestHandlers"
  76. #define DS_OBJECT_VENDORS L"Vendors"
  77. #define DS_OBJECT_RADIUSGROUPS L"RADIUS Server Groups"
  78. #define DS_OBJECT_PROXY_POLICIES L"Proxy Policies"
  79. #define DS_OBJECT_PROXY_PROFILES L"Proxy Profiles"
  80. ///////////////////
  81. // Record Set Names
  82. //
  83. #define RECORD_SET_DICTIONARY_ATTRIBUTES L"Attributes"
  84. #define RECORD_SET_DICTIONARY_ENUMERATORS L"Enumerators"
  85. ///////////////////////////
  86. // Class Names and Prog IDs
  87. //
  88. #define SDO_CLASS_NAME_ATTRIBUTE L"Attribute"
  89. #define SDO_CLASS_NAME_ATTRIBUTE_VALUE L"AttributeValue"
  90. #define SDO_CLASS_NAME_CLIENT L"Client"
  91. #define SDO_CLASS_NAME_CONDITION L"Condition"
  92. #define SDO_CLASS_NAME_PROFILE L"msRADIUSProfile" // ADSI Class
  93. #define SDO_CLASS_NAME_POLICY L"msNetworkPolicy" // ADSI Class
  94. #define SDO_CLASS_NAME_USER L"user" // ADSI Class
  95. #define SDO_CLASS_NAME_DICTIONARY L"Dictionary"
  96. #define SDO_CLASS_NAME_SERVICE L"Service"
  97. #define SDO_CLASS_NAME_COMPONENT L"Component"
  98. #define SDO_CLASS_NAME_VENDOR L"Vendor"
  99. #define SDO_PROG_ID_ATTRIBUTE L"IAS.SdoAttribute"
  100. #define SDO_PROG_ID_ATTRIBUTE_VALUE L"IAS.SdoAttributeValue"
  101. #define SDO_PROG_ID_CLIENT L"IAS.SdoClient"
  102. #define SDO_PROG_ID_CONDITION L"IAS.SdoCondition"
  103. #define SDO_PROG_ID_PROFILE L"IAS.SdoProfile"
  104. #define SDO_PROG_ID_POLICY L"IAS.SdoPolicy"
  105. #define SDO_PROG_ID_USER L"IAS.SdoUser"
  106. #define SDO_PROG_ID_DICTIONARY L"IAS.SdoDictionary"
  107. #define SDO_PROG_ID_SERVICE L"IAS.SdoServiceIAS"
  108. #define SDO_PROG_ID_VENDOR L"IAS.SdoVendor"
  109. #define SDO_PROG_ID_RADIUSGROUP L"IAS.SdoRadiusServerGroup"
  110. #define SDO_PROG_ID_RADIUSSERVER L"IAS.SdoRadiusServer"
  111. // Wrap ATL Multi-Threaded Com Base Class Critical Section
  112. //
  113. class CSdoLock
  114. {
  115. public:
  116. CSdoLock(CComObjectRootEx<CComMultiThreadModel>& T) throw()
  117. : m_theLock(T)
  118. { m_theLock.Lock(); }
  119. ~CSdoLock() throw()
  120. { m_theLock.Unlock(); }
  121. protected:
  122. CComObjectRootEx<CComMultiThreadModel>& m_theLock;
  123. };
  124. /////////////////////////////////////////////////////////////////////////////
  125. // Class: CSdo
  126. //
  127. // Description: All SDOs that export ISdo inherit from this class
  128. /////////////////////////////////////////////////////////////////////////////
  129. class ATL_NO_VTABLE CSdo :
  130. public CComObjectRootEx<CComMultiThreadModel>,
  131. public IDispatchImpl<ISdo, &IID_ISdo, &LIBID_SDOIASLib>
  132. {
  133. public:
  134. //////////////////////////////////////////////////////////////////////////
  135. CSdo();
  136. //////////////////////////////////////////////////////////////////////////
  137. virtual ~CSdo();
  138. //////////////////////////////////////////////////////////////////////////
  139. HRESULT InternalInitialize(
  140. /*[in]*/ LPCWSTR lpszSdoName,
  141. /*[in]*/ LPCWSTR lpszSdoProgId,
  142. /*[in]*/ ISdoMachine* pSdoMachine,
  143. /*[in]*/ IDataStoreObject* pDSObject,
  144. /*[in]*/ ISdoCollection* pParent,
  145. /*[in]*/ bool fInitNew
  146. ) throw();
  147. //////////////////////////////////////////////////////////////////////////
  148. HRESULT InternalInitialize(
  149. /*[in]*/ LPCWSTR lpszSdoName,
  150. /*[in]*/ LPCWSTR lpszSdoProgId,
  151. /*[in]*/ ISdoSchema* pSdoSchema,
  152. /*[in]*/ IDataStoreObject* pDSObject,
  153. /*[in]*/ ISdoCollection* pParent,
  154. /*[in]*/ bool fInitNew
  155. ) throw();
  156. //////////////////
  157. // ISdo Interface
  158. //////////////////
  159. //////////////////////////////////////////////////////////////////////////
  160. STDMETHOD(GetPropertyInfo)(
  161. /*[in]*/ LONG Id,
  162. /*[out]*/ IUnknown** ppSdoPropertyInfo
  163. );
  164. //////////////////////////////////////////////////////////////////////////
  165. STDMETHOD(GetProperty)(
  166. /*[in]*/ LONG Id,
  167. /*[out]*/ VARIANT* pValue
  168. );
  169. //////////////////////////////////////////////////////////////////////////
  170. STDMETHOD(PutProperty)(
  171. /*[in]*/ LONG Id,
  172. /*[in]*/ VARIANT* pValue
  173. );
  174. //////////////////////////////////////////////////////////////////////////
  175. STDMETHOD(ResetProperty)(
  176. /*[in]*/ LONG Id
  177. );
  178. //////////////////////////////////////////////////////////////////////////
  179. STDMETHOD(Apply)(void);
  180. //////////////////////////////////////////////////////////////////////////
  181. STDMETHOD(Restore)(void);
  182. //////////////////////////////////////////////////////////////////////////////
  183. STDMETHOD(get__NewEnum)(
  184. /*[out]*/ IUnknown** pEnumVARIANT // Property Enumerator
  185. );
  186. protected:
  187. //////////////////////////////////////////////////////////////////////////
  188. virtual HRESULT FinalInitialize(
  189. /*[in]*/ bool fInitNew,
  190. /*[in]*/ ISdoMachine* pAttachedMachine
  191. ) throw();
  192. //////////////////////////////////////////////////////////////////////////
  193. void InternalShutdown(void) throw();
  194. //////////////////////////////////////////////////////////////////////////
  195. HRESULT LoadProperties() throw();
  196. //////////////////////////////////////////////////////////////////////////
  197. HRESULT SaveProperties() throw();
  198. //////////////////////////////////////////////////////////////////////////
  199. BOOL IsSdoInitialized(void) const throw()
  200. { return m_fSdoInitialized; }
  201. //////////////////////////////////////////////////////////////////////////
  202. void NoPersist(void) throw();
  203. //////////////////////////////////////////////////////////////////////////
  204. virtual HRESULT InitializeProperty(LONG lPropertyId) throw()
  205. { return S_OK; }
  206. //////////////////////////////////////////////////////////////////////////
  207. HRESULT GetPropertyInternal(
  208. /*[in]*/ LONG lPropertyId,
  209. /*[in]*/ VARIANT* pValue
  210. ) throw();
  211. //////////////////////////////////////////////////////////////////////////
  212. HRESULT PutPropertyInternal(
  213. /*[in]*/ LONG lPropertyId,
  214. /*[in]*/ VARIANT* pValue
  215. ) throw();
  216. //////////////////////////////////////////////////////////////////////////
  217. HRESULT ChangePropertyDefaultInternal(
  218. /*[in]*/ LONG lPropertyId,
  219. /*[in]*/ VARIANT* pValue
  220. ) throw();
  221. //////////////////////////////////////////////////////////////////////////
  222. HRESULT InitializeCollection(
  223. LONG CollectionPropertyId,
  224. LPCWSTR lpszCreateClassId,
  225. ISdoMachine* pSdoMachine,
  226. IDataStoreContainer* pDSContainer,
  227. size_t maxSize = INFINITE
  228. ) throw();
  229. //////////////////////////////////////////////////////////////////////////
  230. virtual HRESULT Load(void) throw();
  231. //////////////////////////////////////////////////////////////////////////
  232. virtual HRESULT Save(void) throw();
  233. //////////////////////////////////////////////////////////////////////////
  234. virtual HRESULT ValidateProperty(
  235. /*[in]*/ PSDOPROPERTY pProperty,
  236. /*[in]*/ VARIANT* pValue
  237. ) throw();
  238. //////////////////////////////////////////////////////////////////////////
  239. typedef map<LONG, CSdoProperty*> PropertyMap;
  240. typedef PropertyMap::iterator PropertyMapIterator;
  241. // This SDO's property map
  242. PropertyMap m_PropertyMap;
  243. // Parent object
  244. ISdoCollection* m_pParent;
  245. // Data store object into which this SDO is persisted
  246. IDataStoreObject* m_pDSObject;
  247. private:
  248. CSdo(const CSdo& rhs);
  249. CSdo& operator = (CSdo& rhs);
  250. /////////////
  251. // Properties
  252. /////////////
  253. // Sdo state flag - Set to true once the SDO has been initialized
  254. BOOL m_fSdoInitialized;
  255. // Persist the object at apply time
  256. BOOL m_fPersistOnApply;
  257. // Set if object has been persisted (and can therfore be restored)
  258. BOOL m_fIsPersisted;
  259. ////////////////////
  260. // Private Functions
  261. ////////////////////
  262. //////////////////////////////////////////////////////////////////////////
  263. void AllocateProperties(
  264. /*[in]*/ ISdoClassInfo* pSdoClassInfo
  265. ) throw (_com_error);
  266. //////////////////////////////////////////////////////////////////////////
  267. void FreeProperties(void) throw();
  268. //////////////////////////////////////////////////////////////////////////
  269. HRESULT GetDatastoreName(
  270. /*[in*/ VARIANT* pDSName
  271. ) throw();
  272. };
  273. #endif //__IAS_SDO_H_