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.

234 lines
6.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: dsconnection.h
  6. //
  7. // Project: Everest
  8. //
  9. // Description: IAS Server Data Object Definition
  10. //
  11. // Author: TLP
  12. //
  13. // When Who What
  14. // ---- --- ----
  15. // 4/6/98 TLP Original Version
  16. //
  17. ///////////////////////////////////////////////////////////////////////////
  18. #ifndef _INC_IAS_SDO_CONNECTION_H_
  19. #define _INC_IAS_SDO_CONNECTION_H_
  20. #include "resource.h" // main symbols
  21. #include <ias.h>
  22. #include <sdoiaspriv.h>
  23. ///////////////////////////////////////////////////////////////////////////
  24. // IAS Data Store Information
  25. ///////////////////////////////////////////////////////////////////////////
  26. #define IAS_SERVICE_DIRECTORY L"ProductDir"
  27. #define IAS_DICTIONARY_LOCATION L"dnary.mdb"
  28. #define IAS_CONFIG_DB_LOCATION L"ias.mdb"
  29. #define IAS_MAX_CONFIG_PATH (MAX_PATH + 1)
  30. #define IAS_MIXED_MODE 1
  31. ///////////////////////////////////////////////////////////////////////////
  32. // Active Directory Data Store Information
  33. ///////////////////////////////////////////////////////////////////////////
  34. #define IAS_NTDS_ROOT_DSE (LPWSTR)L"RootDSE"
  35. #define IAS_NTDS_LDAP_PROVIDER (LPWSTR)L"LDAP://"
  36. #define IAS_NTDS_CONFIG_NAMING_CONTEXT (LPWSTR)L"configurationNamingContext"
  37. #define IAS_NTDS_DEFAULT_NAMING_CONTEXT (LPWSTR)L"defaultNamingContext"
  38. #define IAS_NTDS_MIXED_MODE_FLAG (LPWSTR)L"nTMixedDomain"
  39. #define IAS_NTDS_SAM_ACCOUNT_NAME (LPWSTR)L"sAMAccountName"
  40. #define IAS_NTDS_COMMON_NAMES (LPWSTR)L"cn=RADIUS,cn=Services,"
  41. // I don't think we can assume a fully qualified DNS name will be less
  42. // than or equal to MAX_PATH in length, but it's too risky to replace
  43. // m_szServerName with a dynamically allocated buffer. Furthermore, there
  44. // appear to be lots of other places in the SDO code that make this
  45. // faulty assumption.
  46. const DWORD IAS_MAX_SERVER_NAME = MAX_PATH;
  47. ///////////////////////////////////////////////////////////////////////////
  48. // Data Store Connection
  49. ///////////////////////////////////////////////////////////////////////////
  50. class CDsConnection
  51. {
  52. public:
  53. CDsConnection();
  54. virtual ~CDsConnection();
  55. virtual HRESULT Connect(
  56. /*[in]*/ LPCWSTR lpszServerName,
  57. /*[in]*/ LPCWSTR lpszUserName,
  58. /*[in]*/ LPCWSTR lpszPassword
  59. ) = 0;
  60. virtual HRESULT InitializeDS(void) = 0;
  61. virtual void Disconnect(void) = 0;
  62. bool IsConnected() const;
  63. bool IsRemoteServer() const;
  64. LPCWSTR GetConfigPath() const;
  65. LPCWSTR GetServerName() const;
  66. bool SetServerName(
  67. /*[in]*/ LPCWSTR lpwszServerName,
  68. /*[in]*/ bool bDefaultToLocal
  69. );
  70. IDataStore2* GetDSRoot(BOOL bAddRef = FALSE) const;
  71. IDataStoreObject* GetDSRootObject(BOOL bAddRef = FALSE) const;
  72. IDataStoreContainer* GetDSRootContainer(BOOL bAddRef = FALSE) const;
  73. protected:
  74. typedef enum _DSCONNECTIONSTATE
  75. {
  76. DISCONNECTED,
  77. CONNECTED
  78. } DSCONNECTIONSTATE;
  79. DSCONNECTIONSTATE m_eState;
  80. bool m_bIsRemoteServer;
  81. bool m_bIsMixedMode;
  82. bool m_bInitializedDS;
  83. IDataStore2* m_pDSRoot;
  84. IDataStoreObject* m_pDSRootObject;
  85. IDataStoreContainer* m_pDSRootContainer;
  86. WCHAR m_szServerName[IAS_MAX_SERVER_NAME + 1];
  87. WCHAR m_szConfigPath[IAS_MAX_CONFIG_PATH + 1];
  88. private:
  89. // Disallow copy and assignment
  90. //
  91. CDsConnection(CDsConnection& theConnection);
  92. CDsConnection& operator=(CDsConnection& theConnection);
  93. };
  94. typedef CDsConnection* PDATA_STORE_CONNECTION;
  95. //////////////////////////////////////////////////////////////////////////////
  96. inline bool CDsConnection::IsConnected() const
  97. { return ( CONNECTED == m_eState ? true : false ); }
  98. //////////////////////////////////////////////////////////////////////////////
  99. inline bool CDsConnection::IsRemoteServer() const
  100. { return !m_bIsRemoteServer; }
  101. //////////////////////////////////////////////////////////////////////////////
  102. inline IDataStore2* CDsConnection::GetDSRoot(BOOL bAddRef) const
  103. {
  104. if ( bAddRef )
  105. m_pDSRoot->AddRef();
  106. return m_pDSRoot;
  107. }
  108. //////////////////////////////////////////////////////////////////////////////
  109. inline IDataStoreObject* CDsConnection::GetDSRootObject(BOOL bAddRef) const
  110. {
  111. if ( bAddRef )
  112. m_pDSRootObject->AddRef();
  113. return m_pDSRootObject;
  114. }
  115. //////////////////////////////////////////////////////////////////////////////
  116. inline IDataStoreContainer* CDsConnection::GetDSRootContainer(BOOL bAddRef) const
  117. {
  118. if ( bAddRef )
  119. m_pDSRoot->AddRef();
  120. return m_pDSRootContainer;
  121. }
  122. //////////////////////////////////////////////////////////////////////////////
  123. inline LPCWSTR CDsConnection::GetConfigPath() const
  124. { return (LPCWSTR)m_szConfigPath; }
  125. //////////////////////////////////////////////////////////////////////////////
  126. inline LPCWSTR CDsConnection::GetServerName() const
  127. { return (LPCWSTR)m_szServerName; }
  128. //////////////////////////////////////////////////////////////////////////////
  129. // IAS Data Store Connection
  130. //////////////////////////////////////////////////////////////////////////////
  131. class CDsConnectionIAS : public CDsConnection
  132. {
  133. public:
  134. HRESULT Connect(
  135. /*[in]*/ LPCWSTR lpszServerName,
  136. /*[in]*/ LPCWSTR lpszUserName,
  137. /*[in]*/ LPCWSTR lpszPassword
  138. );
  139. HRESULT InitializeDS(void);
  140. void Disconnect(void);
  141. private:
  142. bool SetConfigPath(void);
  143. };
  144. //////////////////////////////////////////////////////////////////////////////
  145. // Active Directory Data Store Connection
  146. //////////////////////////////////////////////////////////////////////////////
  147. class CDsConnectionAD : public CDsConnection
  148. {
  149. public:
  150. CDsConnectionAD()
  151. : CDsConnection(), m_bMixedMode(false) { }
  152. HRESULT Connect(
  153. /*[in]*/ LPCWSTR lpszServerName,
  154. /*[in]*/ LPCWSTR lpszUserName,
  155. /*[in]*/ LPCWSTR lpszPassword
  156. );
  157. HRESULT InitializeDS(void);
  158. void Disconnect(void);
  159. bool IsMixedMode(void) const;
  160. private:
  161. HRESULT GetNamingContexts(
  162. /*[in]*/ VARIANT* pvtConfigNamingContext,
  163. /*[in]*/ VARIANT* pvtDefaultNamingContext
  164. );
  165. HRESULT SetMode(
  166. /*[out]*/ VARIANT* pvtDefaultNamingContext
  167. );
  168. HRESULT SetConfigPath(
  169. /*[out]*/ VARIANT* pvtConfigNamingContext
  170. );
  171. bool m_bMixedMode;
  172. };
  173. //////////////////////////////////////////////////////////////////////////////
  174. inline bool CDsConnectionAD::IsMixedMode() const
  175. { return m_bMixedMode; }
  176. #endif // _INC_IAS_SDO_CONNECTION_H_