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.

160 lines
4.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: sdofactory.cpp
  6. //
  7. // Project: Everest
  8. //
  9. // Description: IAS Server Data Object Factory
  10. //
  11. // When Who What
  12. // ---- --- ----
  13. // 9/8/98 TLP Original Version
  14. //
  15. ///////////////////////////////////////////////////////////////////////////
  16. #include "stdafx.h"
  17. #include <ias.h>
  18. #include "sdofactory.h"
  19. #include "sdo.h"
  20. #include "sdoschema.h"
  21. #include "sdocollection.h"
  22. #include "sdoclient.h"
  23. #include "sdocomponent.h"
  24. #include "sdocondition.h"
  25. #include "sdoprofile.h"
  26. #include "sdopolicy.h"
  27. #include "sdoserviceias.h"
  28. #include "sdouser.h"
  29. #include "sdovendor.h"
  30. #include "sdoservergroup.h"
  31. //////////////////////////////////////////////////////////////////////////////
  32. BEGIN_SDOFACTORY_MAP(SdoClassFactory1)
  33. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_CLIENT, CSdoClient)
  34. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_CONDITION, CSdoCondition)
  35. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_POLICY, CSdoPolicy)
  36. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_PROFILE, CSdoProfile)
  37. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_SERVICE, CSdoServiceIAS)
  38. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_USER, CSdoUser)
  39. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_VENDOR, CSdoVendor)
  40. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_RADIUSGROUP, SdoServerGroup)
  41. DEFINE_SDOFACTORY_ENTRY_1(SDO_PROG_ID_RADIUSSERVER, SdoServer)
  42. END_SDOFACTORY_MAP()
  43. //////////////////////////////////////////////////////////////////////////////
  44. ISdo* MakeSDO(
  45. /*[in]*/ LPCWSTR lpszSdoName,
  46. /*[in]*/ LPCWSTR lpszSdoProgId,
  47. /*[in]*/ ISdoMachine* pAttachedMachine,
  48. /*[in]*/ IDataStoreObject* pDSObject,
  49. /*[in]*/ ISdoCollection* pParent,
  50. /*[in]*/ bool fInitNew
  51. )
  52. {
  53. ISdo* pSdo = NULL;
  54. PSDO_CLASS_FACTORY_INFO pFactoryInfo = SdoClassFactory1;
  55. while ( pFactoryInfo->pProgId )
  56. {
  57. if ( 0 == lstrcmp(pFactoryInfo->pProgId, lpszSdoProgId) )
  58. {
  59. _ASSERT ( NULL != pFactoryInfo->pfnFactory1 );
  60. pSdo = (pFactoryInfo->pfnFactory1)(
  61. lpszSdoName,
  62. lpszSdoProgId,
  63. pAttachedMachine,
  64. pDSObject,
  65. pParent,
  66. fInitNew
  67. );
  68. break;
  69. }
  70. pFactoryInfo++;
  71. if ( NULL == pFactoryInfo->pProgId )
  72. {
  73. // Default to creating a component SDO
  74. //
  75. _ASSERT ( NULL != pFactoryInfo->pfnFactory1 );
  76. pSdo = (pFactoryInfo->pfnFactory1)(
  77. lpszSdoName,
  78. lpszSdoProgId,
  79. pAttachedMachine,
  80. pDSObject,
  81. pParent,
  82. fInitNew
  83. );
  84. }
  85. }
  86. return pSdo;
  87. }
  88. //////////////////////////////////////////////////////////////////////////////
  89. BEGIN_SDOFACTORY_MAP(SdoClassFactory2)
  90. END_SDOFACTORY_MAP()
  91. //////////////////////////////////////////////////////////////////////////////
  92. ISdo* MakeSDO(
  93. /*[in]*/ LPCWSTR lpszSdoName,
  94. /*[in]*/ LPCWSTR lpszSdoProgId,
  95. /*[in]*/ ISdoSchema* pSdoSchema,
  96. /*[in]*/ IDataStoreObject* pDSObject,
  97. /*[in]*/ ISdoCollection* pParent,
  98. /*[in]*/ bool fInitNew
  99. )
  100. {
  101. ISdo* pSdo = NULL;
  102. PSDO_CLASS_FACTORY_INFO pFactoryInfo = SdoClassFactory2;
  103. while ( pFactoryInfo->pProgId )
  104. {
  105. if ( 0 == lstrcmp(pFactoryInfo->pProgId, lpszSdoProgId) )
  106. {
  107. _ASSERT ( NULL != pFactoryInfo->pfnFactory2 );
  108. pSdo = (pFactoryInfo->pfnFactory2)(
  109. lpszSdoName,
  110. lpszSdoProgId,
  111. pSdoSchema,
  112. pDSObject,
  113. pParent,
  114. fInitNew
  115. );
  116. break;
  117. }
  118. pFactoryInfo++;
  119. }
  120. return pSdo;
  121. }
  122. //////////////////////////////////////////////////////////////////////////////
  123. ISdoCollection* MakeSDOCollection(
  124. /*[in]*/ LPCWSTR lpszCreateClassId,
  125. /*[in]*/ ISdoMachine* pAttachedMachine,
  126. /*[in]*/ IDataStoreContainer* pDSContainer
  127. )
  128. {
  129. ISdoCollection* pSdoCollection = NULL;
  130. try
  131. {
  132. auto_ptr<SDO_COLLECTION_OBJ> pCollection (new SDO_COLLECTION_OBJ);
  133. if ( SUCCEEDED(pCollection->InternalInitialize(
  134. lpszCreateClassId,
  135. pAttachedMachine,
  136. pDSContainer
  137. )) )
  138. {
  139. pSdoCollection = dynamic_cast<ISdoCollection*>(pCollection.release());
  140. }
  141. else
  142. {
  143. IASTracePrintf("Error in SDO Factory - MakeSDOCollection() - Collection could not be initialized...");
  144. }
  145. }
  146. catch(...)
  147. {
  148. IASTracePrintf("Error in SDO Factory - MakeSDOCollection() - Could not create collection object...");
  149. }
  150. return pSdoCollection;
  151. }