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.

314 lines
8.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dsadminp.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // CoClass for the choose DC dialog object
  12. //
  13. // {8F2AC965-04A2-11d3-82BD-00C04F68928B}
  14. DEFINE_GUID(CLSID_DsAdminChooseDCObj,
  15. 0x8f2ac965, 0x4a2, 0x11d3, 0x82, 0xbd, 0x0, 0xc0, 0x4f, 0x68, 0x92, 0x8b);
  16. //
  17. // Interface to access the choose DC dialog object
  18. //
  19. // {A5F06B5F-04A2-11d3-82BD-00C04F68928B}
  20. DEFINE_GUID(IID_IDsAdminChooseDC,
  21. 0xa5f06b5f, 0x4a2, 0x11d3, 0x82, 0xbd, 0x0, 0xc0, 0x4f, 0x68, 0x92, 0x8b);
  22. #ifndef _DSADMINP_H
  23. #define _DSADMINP_H
  24. // ----------------------------------------------------------------------------
  25. //
  26. // Interface: IDsAdminChooseDC
  27. //
  28. // Implemented by the object CLSID_DsAdminChooseDCObj
  29. //
  30. // Used by: any client needing to invoke the DC selection UI
  31. //
  32. #undef INTERFACE
  33. #define INTERFACE IDsAdminChooseDC
  34. DECLARE_INTERFACE_(IDsAdminChooseDC, IUnknown)
  35. {
  36. // *** IUnknown methods ***
  37. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  38. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  39. STDMETHOD_(ULONG,Release)(THIS) PURE;
  40. // *** IDsAdminChooseDC methods ***
  41. STDMETHOD(InvokeDialog)(THIS_ /*IN*/ HWND hwndParent,
  42. /*IN*/ LPCWSTR lpszTargetDomain,
  43. /*IN*/ LPCWSTR lpszTargetDomainController,
  44. /*IN*/ ULONG uFlags,
  45. /*OUT*/ BSTR* bstrSelectedDC) PURE;
  46. };
  47. /////////////////////////////////////////////////////////////////////
  48. // macros
  49. #define ByteOffset(base, offset) (((LPBYTE)base)+offset)
  50. /////////////////////////////////////////////////////////////////////
  51. // Helper global API's
  52. HRESULT GetAttr( IN IADs* pIADs, IN WCHAR* wzAttr, OUT PADS_ATTR_INFO* ppAttrs );
  53. HRESULT GetStringAttr( IN IADs* pIADs, IN WCHAR* wzAttr, OUT BSTR* pbstr );
  54. HRESULT GetObjectGUID( IN IADs* pIADs, OUT UUID* pUUID );
  55. HRESULT GetObjectGUID( IN IADs* pIADs, OUT BSTR* pbstrObjectGUID );
  56. HRESULT GetADSIServerName(OUT PWSTR* szServer, IN IUnknown* pUnk);
  57. int cchLoadHrMsg( IN HRESULT hr, OUT PTSTR* pptzSysMsg, IN BOOL TryADsIErrors );
  58. void StringErrorFromHr(HRESULT hr, OUT PWSTR* pszError, BOOL TryADsIErrors = TRUE);
  59. /////////////////////////////////////////////////////////////////////
  60. // FSMO Mainipulation API's
  61. class CDSBasePathsInfo; // fwd decl.
  62. enum FSMO_TYPE
  63. {
  64. SCHEMA_FSMO,
  65. RID_POOL_FSMO,
  66. PDC_FSMO,
  67. INFRASTUCTURE_FSMO,
  68. DOMAIN_NAMING_FSMO,
  69. };
  70. HRESULT FindFsmoOwner(IN CDSBasePathsInfo* pCurrentPath,
  71. IN FSMO_TYPE fsmoType,
  72. OUT CDSBasePathsInfo* pFsmoOwnerPath,
  73. OUT PWSTR* pszFsmoOwnerServerName);
  74. HRESULT CheckpointFsmoOwnerTransfer(IN CDSBasePathsInfo* pPathInfo);
  75. HRESULT GracefulFsmoOwnerTransfer(IN CDSBasePathsInfo* pPathInfo, IN FSMO_TYPE fsmoType);
  76. HRESULT ForcedFsmoOwnerTransfer(IN CDSBasePathsInfo* pPathInfo,
  77. IN FSMO_TYPE fsmoType);
  78. /////////////////////////////////////////////////////////////////////
  79. // CDSBasePathsInfo
  80. class CDSBasePathsInfo
  81. {
  82. public:
  83. CDSBasePathsInfo();
  84. ~CDSBasePathsInfo();
  85. // initialization functions
  86. HRESULT InitFromName(LPCWSTR lpszServerOrDomainName);
  87. HRESULT InitFromContainer(IADsContainer* pADsContainerObj);
  88. HRESULT InitFromInfo(CDSBasePathsInfo* pBasePathsInfo);
  89. // accessor functions
  90. IADs* GetRootDSE() { return m_spRootDSE;}
  91. LPCWSTR GetProvider() { return L"LDAP://";}
  92. LPCWSTR GetProviderAndServerName() { return m_szProviderAndServerName;}
  93. LPCWSTR GetServerName() { return m_szServerName;}
  94. LPCWSTR GetDomainName() { return m_szDomainName;}
  95. LPCWSTR GetSchemaNamingContext() { return m_szSchemaNamingContext;}
  96. LPCWSTR GetConfigNamingContext() { return m_szConfigNamingContext;}
  97. LPCWSTR GetDefaultRootNamingContext() {return m_szDefaultNamingContext;}
  98. LPCWSTR GetRootDomainNamingContext() {return m_szRootDomainNamingContext;}
  99. UINT GetDomainBehaviorVersion() { return m_nDomainBehaviorVersion; }
  100. UINT GetForestBehaviorVersion() { return m_nForestBehaviorVersion; }
  101. UINT GetSchemaVersion() { return m_nSchemaVersion; }
  102. // helper functions to compose LDAP paths out of naming contexts
  103. // NOTE: the caller needs to free the memory allocated for the returned
  104. // string by using the operator delete[]
  105. //
  106. int ComposeADsIPath(OUT PWSTR* pszPath, IN LPCWSTR lpszNamingContext);
  107. int GetSchemaPath(OUT PWSTR* s);
  108. int GetConfigPath(OUT PWSTR* s);
  109. int GetDefaultRootPath(OUT PWSTR* s);
  110. int GetRootDomainPath(OUT PWSTR* s);
  111. int GetRootDSEPath(OUT PWSTR* s);
  112. int GetAbstractSchemaPath(OUT PWSTR* s);
  113. int GetPartitionsPath(OUT PWSTR* s);
  114. int GetSchemaObjectPath(IN LPCWSTR lpszObjClass, OUT PWSTR* s);
  115. int GetInfrastructureObjectPath(OUT PWSTR* s);
  116. // display specifiers cache API's
  117. HRESULT GetDisplaySpecifier(LPCWSTR lpszObjectClass, REFIID riid, void** ppv);
  118. HICON GetIcon(LPCWSTR lpszObjectClass, DWORD dwFlags, INT cxIcon, INT cyIcon);
  119. HRESULT GetFriendlyClassName(LPCWSTR lpszObjectClass,
  120. LPWSTR lpszBuffer, int cchBuffer);
  121. HRESULT GetFriendlyAttributeName(LPCWSTR lpszObjectClass,
  122. LPCWSTR lpszAttributeName,
  123. LPWSTR lpszBuffer, int cchBuffer);
  124. BOOL IsClassContainer(LPCWSTR lpszObjectClass, LPCWSTR lpszADsPath, DWORD dwFlags);
  125. HRESULT GetClassCreationInfo(LPCWSTR lpszObjectClass, LPDSCLASSCREATIONINFO* ppdscci);
  126. HRESULT GetAttributeADsType(LPCWSTR lpszAttributeName, ADSTYPE& attrType);
  127. bool IsInitialized() { return m_bIsInitialized; }
  128. UINT AddRef() { return ++m_nRefs; }
  129. UINT Release();
  130. private:
  131. PWSTR m_szServerName; // DNS server (DC) name (e.g. "mydc.mycomp.com.")
  132. PWSTR m_szDomainName; // DNS domain name (e.g. "mydom.mycomp.com.")
  133. PWSTR m_szProviderAndServerName; // LDAP://<server>/
  134. PWSTR m_szSchemaNamingContext;
  135. PWSTR m_szConfigNamingContext;
  136. PWSTR m_szDefaultNamingContext;
  137. PWSTR m_szRootDomainNamingContext;
  138. UINT m_nDomainBehaviorVersion;
  139. UINT m_nForestBehaviorVersion;
  140. UINT m_nSchemaVersion;
  141. UINT m_nRefs;
  142. CComPtr<IADs> m_spRootDSE; // cached connection
  143. CComPtr<IDsDisplaySpecifier> m_spIDsDisplaySpecifier; // pointer to Display Specifier Cache
  144. bool m_bIsInitialized;
  145. HRESULT _InitHelper();
  146. void _Reset();
  147. void _BuildProviderAndServerName();
  148. };
  149. // This is a smart wrapper around the CDSBasePathsInfo class
  150. class CDSSmartBasePathsInfo
  151. {
  152. public:
  153. CDSSmartBasePathsInfo() : m_ptr(0)
  154. {
  155. }
  156. CDSSmartBasePathsInfo(const CDSSmartBasePathsInfo& rhs) : m_ptr(0)
  157. {
  158. Acquire(rhs.m_ptr);
  159. }
  160. CDSSmartBasePathsInfo(CDSBasePathsInfo* ptr) : m_ptr(0)
  161. {
  162. Acquire(ptr);
  163. }
  164. ~CDSSmartBasePathsInfo()
  165. {
  166. if (m_ptr)
  167. {
  168. m_ptr->Release();
  169. m_ptr = 0;
  170. }
  171. }
  172. CDSSmartBasePathsInfo& operator=(const CDSSmartBasePathsInfo& rhs)
  173. {
  174. Acquire(rhs.m_ptr);
  175. return *this;
  176. }
  177. CDSBasePathsInfo* operator->() const
  178. {
  179. return m_ptr;
  180. }
  181. private:
  182. void Acquire(CDSBasePathsInfo* ptr)
  183. {
  184. if (m_ptr)
  185. {
  186. m_ptr->Release();
  187. }
  188. m_ptr = ptr;
  189. if (m_ptr)
  190. {
  191. m_ptr->AddRef();
  192. }
  193. }
  194. CDSBasePathsInfo* m_ptr;
  195. };
  196. ///////////////////////////////////////////////////////////////////////////////
  197. // CDsDisplaySpecOptionsCFHolder
  198. //
  199. // Helper class to cache a DSDISPLAYSPECOPTIONS struct for the
  200. // corresponding clipboard format
  201. class CDsDisplaySpecOptionsCFHolder
  202. {
  203. public:
  204. CDsDisplaySpecOptionsCFHolder()
  205. {
  206. m_pDsDisplaySpecOptions = NULL;
  207. }
  208. ~CDsDisplaySpecOptionsCFHolder()
  209. {
  210. if (m_pDsDisplaySpecOptions != NULL)
  211. GlobalFree(m_pDsDisplaySpecOptions);
  212. }
  213. HRESULT Init(CDSBasePathsInfo* pBasePathInfo);
  214. PDSDISPLAYSPECOPTIONS Get();
  215. private:
  216. PDSDISPLAYSPECOPTIONS m_pDsDisplaySpecOptions;
  217. };
  218. //////////////////////////////////////////////////////////////////////////
  219. // CToggleTextControlHelper
  220. class CToggleTextControlHelper
  221. {
  222. public:
  223. CToggleTextControlHelper();
  224. ~CToggleTextControlHelper();
  225. BOOL Init(HWND hWnd);
  226. void SetToggleState(BOOL bFirst);
  227. private:
  228. HWND m_hWnd;
  229. WCHAR* m_pTxt1;
  230. WCHAR* m_pTxt2;
  231. };
  232. #endif //_DSADMINP_H