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.

258 lines
7.3 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. // helper functions to compose LDAP paths out of naming contexts
  102. // NOTE: the caller needs to free the memory allocated for the returned
  103. // string by using the operator delete[]
  104. //
  105. int ComposeADsIPath(OUT PWSTR* pszPath, IN LPCWSTR lpszNamingContext);
  106. int GetSchemaPath(OUT PWSTR* s);
  107. int GetConfigPath(OUT PWSTR* s);
  108. int GetDefaultRootPath(OUT PWSTR* s);
  109. int GetRootDomainPath(OUT PWSTR* s);
  110. int GetRootDSEPath(OUT PWSTR* s);
  111. int GetAbstractSchemaPath(OUT PWSTR* s);
  112. int GetPartitionsPath(OUT PWSTR* s);
  113. int GetSchemaObjectPath(IN LPCWSTR lpszObjClass, OUT PWSTR* s);
  114. int GetInfrastructureObjectPath(OUT PWSTR* s);
  115. // display specifiers cache API's
  116. HRESULT GetDisplaySpecifier(LPCWSTR lpszObjectClass, REFIID riid, void** ppv);
  117. HICON GetIcon(LPCWSTR lpszObjectClass, DWORD dwFlags, INT cxIcon, INT cyIcon);
  118. HRESULT GetFriendlyClassName(LPCWSTR lpszObjectClass,
  119. LPWSTR lpszBuffer, int cchBuffer);
  120. HRESULT GetFriendlyAttributeName(LPCWSTR lpszObjectClass,
  121. LPCWSTR lpszAttributeName,
  122. LPWSTR lpszBuffer, int cchBuffer);
  123. BOOL IsClassContainer(LPCWSTR lpszObjectClass, LPCWSTR lpszADsPath, DWORD dwFlags);
  124. HRESULT GetClassCreationInfo(LPCWSTR lpszObjectClass, LPDSCLASSCREATIONINFO* ppdscci);
  125. bool IsInitialized() { return m_bIsInitialized; }
  126. UINT AddRef() { return ++m_nRefs; }
  127. UINT Release();
  128. private:
  129. PWSTR m_szServerName; // DNS server (DC) name (e.g. "mydc.mycomp.com.")
  130. PWSTR m_szDomainName; // DNS domain name (e.g. "mydom.mycomp.com.")
  131. PWSTR m_szProviderAndServerName; // LDAP://<server>/
  132. PWSTR m_szSchemaNamingContext;
  133. PWSTR m_szConfigNamingContext;
  134. PWSTR m_szDefaultNamingContext;
  135. PWSTR m_szRootDomainNamingContext;
  136. UINT m_nDomainBehaviorVersion;
  137. UINT m_nForestBehaviorVersion;
  138. UINT m_nRefs;
  139. CComPtr<IADs> m_spRootDSE; // cached connection
  140. CComPtr<IDsDisplaySpecifier> m_spIDsDisplaySpecifier; // pointer to Display Specifier Cache
  141. bool m_bIsInitialized;
  142. HRESULT _InitHelper();
  143. void _Reset();
  144. void _BuildProviderAndServerName();
  145. };
  146. ///////////////////////////////////////////////////////////////////////////////
  147. // CDsDisplaySpecOptionsCFHolder
  148. //
  149. // Helper class to cache a DSDISPLAYSPECOPTIONS struct for the
  150. // corresponding clipboard format
  151. class CDsDisplaySpecOptionsCFHolder
  152. {
  153. public:
  154. CDsDisplaySpecOptionsCFHolder()
  155. {
  156. m_pDsDisplaySpecOptions = NULL;
  157. }
  158. ~CDsDisplaySpecOptionsCFHolder()
  159. {
  160. if (m_pDsDisplaySpecOptions != NULL)
  161. GlobalFree(m_pDsDisplaySpecOptions);
  162. }
  163. HRESULT Init(CDSBasePathsInfo* pBasePathInfo);
  164. PDSDISPLAYSPECOPTIONS Get();
  165. private:
  166. PDSDISPLAYSPECOPTIONS m_pDsDisplaySpecOptions;
  167. };
  168. //////////////////////////////////////////////////////////////////////////
  169. // CToggleTextControlHelper
  170. class CToggleTextControlHelper
  171. {
  172. public:
  173. CToggleTextControlHelper();
  174. ~CToggleTextControlHelper();
  175. BOOL Init(HWND hWnd);
  176. void SetToggleState(BOOL bFirst);
  177. private:
  178. HWND m_hWnd;
  179. WCHAR* m_pTxt1;
  180. WCHAR* m_pTxt2;
  181. };
  182. #endif //_DSADMINP_H