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.

894 lines
25 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Windows NT Directory Service Administration SnapIn
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: dssnap.h
  9. //
  10. // Contents: DS App
  11. //
  12. // History: 02-Oct-96 WayneSc Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __DSSNAP_H__
  16. #define __DSSNAP_H__
  17. #ifndef __DSCOOKIE_H__
  18. #include "dscookie.h"
  19. #endif
  20. #ifndef __DSCACHE_H__
  21. #include "dscache.h" // CDSCache
  22. #endif
  23. #define OPCODE_MOVE 0x00000001L
  24. #define OPCODE_DELETE 0x00000002L
  25. // this isn't really a context menu op code, its a flag we use to know
  26. // which icon to return for this object if the enumberation failed
  27. // see dssnap.cpp->ChangeScopeItemIcon()
  28. #define OPCODE_ENUM_FAILED 0x00000004L
  29. // another pseudo opcode, to track whether we're enumerating or
  30. // expanding
  31. #define OPCODE_EXPAND_IN_PROGRESS 0x00000008L
  32. #define DS_DELETE_OCCURRED 900
  33. #define DS_RENAME_OCCURRED 901
  34. #define DS_MOVE_OCCURRED 902
  35. #define DS_CREATE_OCCURRED 903
  36. #define DS_REFRESH_REQUESTED 904
  37. #define DS_VERB_UPDATE 905
  38. #define DS_ICON_STRIP_UPDATE 907
  39. #define DS_HAVE_DATA 908
  40. #define DS_UPDATE_OCCURRED 909
  41. #define DS_MULTIPLE_DELETE_OCCURRED 910
  42. #define DS_MULTIPLE_MOVE_OCCURRED 911
  43. #define DS_CHECK_COLUMN_WIDTHS 912
  44. #define DS_IS_COOKIE_SELECTION 913
  45. #define DS_CREATE_OCCURRED_RESULT_PANE 914
  46. #define DS_DELAYED_EXPAND 915
  47. #define DS_SORT_RESULT_PANE 916
  48. #define DS_UPDATE_VISIBLE_COLUMNS 917
  49. #define DS_UPDATE_OBJECT_COUNT 918
  50. #define DS_UNSELECT_OBJECT 919
  51. #define DS_DEFAULT_COLUMN_COUNT 3
  52. #define DEFAULT_NAME_COL_WIDTH 125
  53. #define DEFAULT_TYPE_COL_WIDTH 175
  54. #define DEFAULT_DESC_COL_WIDTH 400
  55. #define NARROW_DESC_COL_WIDTH 200
  56. // forward declarations
  57. class CDSCookie;
  58. class CDSQueryFilter;
  59. class CHiddenWnd;
  60. class CDSQueryResult;
  61. class CWorkerThread;
  62. struct CBackgroundThreadInfo;
  63. class CFavoritesNodesHolder;
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CTargetingInfo
  66. class CTargetingInfo
  67. {
  68. public:
  69. CTargetingInfo()
  70. {
  71. m_dwFlags = 0x0;
  72. _InitFromCommandLine();
  73. }
  74. HRESULT Load(IStream* pStm);
  75. HRESULT Save(IStream* pStm, LPCWSTR lpszCurrentTargetName);
  76. BOOL GetSaveCurrent()
  77. {
  78. return (m_dwFlags & m_dwSaveDomainFlag) != 0;
  79. }
  80. void SetSaveCurrent(BOOL bSave)
  81. {
  82. if (bSave)
  83. m_dwFlags |= m_dwSaveDomainFlag;
  84. else
  85. m_dwFlags &= ~m_dwSaveDomainFlag;
  86. }
  87. LPCWSTR GetTargetString() { return m_szStoredTargetName; }
  88. LPCWSTR GetRootRDN() { return m_szRootRDN;}
  89. #ifdef _MMC_ISNAPIN_PROPERTY
  90. HRESULT InitFromSnapinProperties(long cProps, //property count
  91. MMC_SNAPIN_PROPERTY* pProps //properties array
  92. );
  93. #endif // _MMC_ISNAPIN_PROPERTY
  94. private:
  95. void _InitFromCommandLine();
  96. DWORD m_dwFlags;
  97. CString m_szStoredTargetName;
  98. CString m_szRootRDN;
  99. static const DWORD m_dwSaveDomainFlag;
  100. };
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CIconManager
  103. class CIconManager
  104. {
  105. public:
  106. CIconManager()
  107. {
  108. m_pScpImageList = NULL;
  109. // set the special indexes to invalid values
  110. m_iRootIconIndex = m_iRootIconErrIndex =
  111. m_iWaitIconIndex = m_iWarnIconIndex =
  112. m_iFavoritesIconIndex = m_iQueryIconIndex =
  113. m_iQueryInvalidIconIndex = 0;
  114. }
  115. ~CIconManager()
  116. {
  117. }
  118. HRESULT Init(IImageList* pScpImageList, SnapinType snapintype);
  119. HRESULT FillInIconStrip(IImageList* pImageList);
  120. HRESULT AddClassIcon(IN LPCWSTR lpszClass,
  121. IN MyBasePathsInfo* pPathInfo,
  122. IN DWORD dwFlags,
  123. INOUT int* pnIndex);
  124. HRESULT AddIcon(IN HICON hiClass16, IN HICON hiClass32, INOUT int* pnIndex);
  125. int GetRootIndex() { return m_iRootIconIndex;}
  126. int GetRootErrIndex() { return m_iRootIconErrIndex;}
  127. int GetWaitIndex() { return m_iWaitIconIndex;}
  128. int GetWarnIndex() { return m_iWarnIconIndex;}
  129. int GetFavoritesIndex() { return m_iFavoritesIconIndex;}
  130. int GetQueryIndex() { return m_iQueryIconIndex;}
  131. int GetQueryInvalidIndex() { return m_iQueryInvalidIconIndex; }
  132. private:
  133. IImageList* m_pScpImageList; // no addref, lifetime of IComponentData
  134. class CIconInfo
  135. {
  136. public:
  137. CIconInfo() { m_hiClass16 = m_hiClass32 = NULL;}
  138. HICON m_hiClass16;
  139. HICON m_hiClass32;
  140. };
  141. class CIconInfoList : public CList <CIconInfo*, CIconInfo*>
  142. {
  143. public:
  144. ~CIconInfoList()
  145. {
  146. while (!IsEmpty())
  147. delete RemoveHead();
  148. }
  149. };
  150. CIconInfoList m_IconInfoList; // list of icon handles
  151. // special icon indexes we need to know about
  152. int m_iRootIconIndex;
  153. int m_iRootIconErrIndex;
  154. int m_iWaitIconIndex;
  155. int m_iWarnIconIndex;
  156. int m_iFavoritesIconIndex;
  157. int m_iQueryIconIndex;
  158. int m_iQueryInvalidIconIndex;
  159. HRESULT _LoadIconFromResource(IN UINT nIconResID, INOUT int* pnIndex);
  160. int _GetBaseIndex() { return 1;}
  161. int _GetNextFreeIndex()
  162. { return (int)(m_IconInfoList.GetCount() + _GetBaseIndex());}
  163. };
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CInternalFormatCracker
  166. class CInternalFormatCracker
  167. {
  168. public:
  169. CInternalFormatCracker()
  170. {
  171. m_pInternalFormat = NULL;
  172. }
  173. ~CInternalFormatCracker()
  174. {
  175. _Free();
  176. }
  177. BOOL HasData() { return m_pInternalFormat != NULL;}
  178. HRESULT Extract(LPDATAOBJECT lpDataObject);
  179. LPDATAOBJECT ExtractMultiSelect(LPDATAOBJECT lpDataObject);
  180. CUINode* GetCookie(UINT nIndex = 0)
  181. {
  182. ASSERT(m_pInternalFormat != NULL);
  183. if (nIndex == 0)
  184. {
  185. return m_pInternalFormat->m_cookie;
  186. }
  187. else if ( (m_pInternalFormat->m_p_cookies != NULL) &&
  188. (nIndex < m_pInternalFormat->m_cookie_count))
  189. {
  190. return m_pInternalFormat->m_p_cookies[nIndex-1];
  191. }
  192. ASSERT(FALSE);
  193. return NULL;
  194. }
  195. UINT GetCookieCount()
  196. {
  197. ASSERT(m_pInternalFormat != NULL);
  198. return m_pInternalFormat->m_cookie_count;
  199. }
  200. DATA_OBJECT_TYPES GetType()
  201. {
  202. ASSERT(m_pInternalFormat != NULL);
  203. return m_pInternalFormat->m_type;
  204. }
  205. SnapinType GetSnapinType()
  206. {
  207. ASSERT(m_pInternalFormat != NULL);
  208. return m_pInternalFormat->m_snapintype;
  209. }
  210. private:
  211. INTERNAL* m_pInternalFormat;
  212. void _Free()
  213. {
  214. if (m_pInternalFormat != NULL)
  215. {
  216. ::GlobalFree(m_pInternalFormat);
  217. m_pInternalFormat = NULL;
  218. }
  219. }
  220. };
  221. /////////////////////////////////////////////////////////////////////
  222. // CObjectNamesFormatCracker
  223. class CObjectNamesFormatCracker
  224. {
  225. public:
  226. CObjectNamesFormatCracker()
  227. {
  228. m_pDsObjectNames = NULL;
  229. }
  230. ~CObjectNamesFormatCracker()
  231. {
  232. _Free();
  233. }
  234. BOOL HasData() { return m_pDsObjectNames != NULL;}
  235. HRESULT Extract(LPDATAOBJECT lpDataObject);
  236. UINT GetCount()
  237. {
  238. ASSERT(m_pDsObjectNames != NULL);
  239. return m_pDsObjectNames->cItems;
  240. }
  241. LPCWSTR GetName(UINT nIndex)
  242. {
  243. ASSERT(nIndex < GetCount());
  244. return (LPCWSTR)ByteOffset(m_pDsObjectNames, m_pDsObjectNames->aObjects[nIndex].offsetName);
  245. }
  246. LPCWSTR GetClass(UINT nIndex)
  247. {
  248. ASSERT(nIndex < GetCount());
  249. return (LPCWSTR)ByteOffset(m_pDsObjectNames, m_pDsObjectNames->aObjects[nIndex].offsetClass);
  250. }
  251. DWORD GetProviderFlags(UINT nIndex)
  252. {
  253. ASSERT(nIndex < GetCount());
  254. return m_pDsObjectNames->aObjects[nIndex].dwProviderFlags;
  255. }
  256. DWORD GetFlags(UINT nIndex)
  257. {
  258. ASSERT(nIndex < GetCount());
  259. return m_pDsObjectNames->aObjects[nIndex].dwFlags;
  260. }
  261. BOOL IsContainer(UINT nIndex)
  262. {
  263. ASSERT(nIndex < GetCount());
  264. return (GetFlags((nIndex) & DSOBJECT_ISCONTAINER) != 0);
  265. }
  266. void Reset() { _Free();}
  267. // Property Page Clipboard formats
  268. static CLIPFORMAT m_cfDsObjectNames;
  269. private:
  270. LPDSOBJECTNAMES m_pDsObjectNames;
  271. void _Free()
  272. {
  273. if (m_pDsObjectNames != NULL)
  274. {
  275. ::GlobalFree(m_pDsObjectNames);
  276. m_pDsObjectNames = NULL;
  277. }
  278. }
  279. };
  280. /////////////////////////////////////////////////////////////////////
  281. // CTopLevelCNInfo
  282. class CTopLevelCNInfo
  283. {
  284. public:
  285. CTopLevelCNInfo()
  286. {
  287. m_nCount = 0;
  288. m_pStringArr = NULL;
  289. m_pdwFlags = NULL;
  290. }
  291. ~CTopLevelCNInfo()
  292. {
  293. Free();
  294. }
  295. BOOL Alloc(UINT nCount)
  296. {
  297. CString* pstr = new CString[nCount];
  298. if (pstr == NULL)
  299. return FALSE;
  300. DWORD* pdw = new DWORD[nCount];
  301. if (pdw == NULL)
  302. {
  303. delete[] pstr;
  304. return FALSE;
  305. }
  306. ZeroMemory( pdw, nCount*sizeof(DWORD) );
  307. m_pStringArr = pstr;
  308. m_pdwFlags = pdw;
  309. m_nCount = nCount;
  310. return TRUE;
  311. }
  312. void Free()
  313. {
  314. m_nCount = 0;
  315. if (m_pStringArr != NULL)
  316. {
  317. delete[] m_pStringArr;
  318. m_pStringArr = NULL;
  319. }
  320. if (m_pdwFlags != NULL)
  321. {
  322. delete[] m_pdwFlags;
  323. m_pdwFlags = NULL;
  324. }
  325. }
  326. UINT m_nCount;
  327. CString* m_pStringArr;
  328. DWORD* m_pdwFlags;
  329. };
  330. #define TOPLEVEL_FLAG_SERVICES_NODE 0x1
  331. /////////////////////////////////////////////////////////////////////
  332. // CDSNotifyHandlerManager
  333. class CDSNotifyHandlerManager
  334. {
  335. private:
  336. class CDSNotifyHandlerInfo
  337. {
  338. public:
  339. CDSNotifyHandlerInfo()
  340. {
  341. m_nRegisteredEvents = 0;
  342. m_nFlags = 0;
  343. m_bTransactionPending = FALSE;
  344. m_bNeedsNotify = FALSE;
  345. }
  346. CComPtr<IDsAdminNotifyHandler> m_spIDsAdminNotifyHandler;
  347. ULONG m_nRegisteredEvents;
  348. ULONG m_nFlags;
  349. CString m_szDisplayString;
  350. BOOL m_bTransactionPending;
  351. BOOL m_bNeedsNotify;
  352. };
  353. public:
  354. CDSNotifyHandlerManager()
  355. {
  356. m_nArrSize = 0;
  357. m_pInfoArr = NULL;
  358. m_state = uninitialized;
  359. }
  360. ~CDSNotifyHandlerManager()
  361. {
  362. _Free();
  363. }
  364. BOOL HasHandlers() { return m_state == hasHandlers;}
  365. HRESULT Init();
  366. HRESULT Load(MyBasePathsInfo* pBasePathInfo); // do the actual extension loading and initialization
  367. // mapping to COM notification interfaces
  368. void Begin(ULONG uEvent, IDataObject* pArg1, IDataObject* pArg2);
  369. void Notify(ULONG nItem, ULONG uEvent);
  370. void End(ULONG uEvent);
  371. // state veriables check
  372. UINT NeedNotifyCount(ULONG uEvent);
  373. // handlers for visualization in confirnation dialog
  374. void SetCheckListBox(CCheckListBox* pCheckListBox, ULONG uEvent);
  375. void ReadFromCheckListBox(CCheckListBox* pCheckListBox, ULONG uEvent);
  376. private:
  377. CDSNotifyHandlerInfo* m_pInfoArr;
  378. UINT m_nArrSize;
  379. enum HandlerState { uninitialized, hasHandlers, noHandlers};
  380. HandlerState m_state;
  381. void _Free()
  382. {
  383. if (m_pInfoArr != NULL)
  384. {
  385. ASSERT(m_nArrSize >0);
  386. delete[] m_pInfoArr;
  387. }
  388. m_nArrSize = 0;
  389. m_pInfoArr = NULL;
  390. m_state = uninitialized;
  391. }
  392. };
  393. /////////////////////////////////////////////////////////////////////
  394. // CDSComponentData
  395. typedef struct _UINODESELECTIONP {
  396. CUINode* pUINode;
  397. BOOL IsSelection;
  398. } UINODESELECTION, * PUINODESELECTION;
  399. class CDSComponentData:
  400. public IComponentData,
  401. public IExtendPropertySheet,
  402. public IExtendContextMenu,
  403. public IPersistStream,
  404. #ifdef _MMC_ISNAPIN_PROPERTY
  405. public ISnapinProperties,
  406. #endif
  407. public ISnapinHelp2,
  408. public CComObjectRoot
  409. {
  410. BEGIN_COM_MAP(CDSComponentData)
  411. COM_INTERFACE_ENTRY(IComponentData)
  412. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  413. COM_INTERFACE_ENTRY(IExtendContextMenu)
  414. COM_INTERFACE_ENTRY(IPersistStream)
  415. #ifdef _MMC_ISNAPIN_PROPERTY
  416. COM_INTERFACE_ENTRY(ISnapinProperties)
  417. #endif
  418. COM_INTERFACE_ENTRY(ISnapinHelp)
  419. COM_INTERFACE_ENTRY(ISnapinHelp2)
  420. END_COM_MAP()
  421. friend class CDSClassCacheItemBase;
  422. friend class CDSEvent;
  423. friend class CDSDataObject;
  424. friend class CDSDirect;
  425. friend class CDSContextMenu;
  426. CDSComponentData();
  427. HRESULT FinalConstruct();
  428. void FinalRelease();
  429. ~CDSComponentData();
  430. public:
  431. // IComponentData interface members
  432. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  433. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  434. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  435. STDMETHOD(Destroy)();
  436. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  437. STDMETHOD(GetDisplayInfo)(LPSCOPEDATAITEM scopeInfo);
  438. STDMETHOD(CompareObjects) (IDataObject * pDataObject, IDataObject * pDataObject2);
  439. // IExtendPropertySheet interface
  440. public:
  441. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  442. LONG_PTR handle,
  443. LPDATAOBJECT lpIDataObject);
  444. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  445. // IExtendContextMenu
  446. public:
  447. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  448. LPCONTEXTMENUCALLBACK pCallbackUnknown,
  449. long *pInsertionAllowed);
  450. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  451. public:
  452. // IPersistStream interface members
  453. STDMETHOD(GetClassID)(CLSID *pClassID);
  454. STDMETHOD(IsDirty)();
  455. STDMETHOD(Load)(IStream *pStm);
  456. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  457. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  458. // ISnapinHelp2 interface members
  459. STDMETHOD(GetHelpTopic)(LPOLESTR* lpCompiledHelpFile);
  460. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFile);
  461. #ifdef _MMC_ISNAPIN_PROPERTY
  462. // ISnapinProperties
  463. STDMETHOD(Initialize) (Properties* pProperties);
  464. STDMETHOD(QueryPropertyNames) (ISnapinPropertiesCallback* pCallback);
  465. STDMETHOD(PropertiesChanged) (long cProperties, MMC_SNAPIN_PROPERTY* pProperties);
  466. #endif //_MMC_ISNAPIN_PROPERTY
  467. public:
  468. virtual SnapinType QuerySnapinType() = 0;
  469. LPCWSTR GetRootPath(void) { return m_RootNode.GetPath(); }
  470. PDSDISPLAYSPECOPTIONS GetDsDisplaySpecOptions()
  471. {
  472. return m_DsDisplaySpecOptionsCFHolder.Get();
  473. }
  474. HRESULT AddClassIcon(IN LPCWSTR lpszClass, IN DWORD dwFlags, INOUT int* pnIndex);
  475. HRESULT FillInIconStrip(IImageList* pImageList);
  476. HWND GetHWnd() { return m_hwnd;}
  477. CRootNode* GetRootNode() { return &m_RootNode;}
  478. CDSDirect* GetActiveDS() { return m_ActiveDS;}
  479. BOOL ExpandComputers();
  480. BOOL IsAdvancedView();
  481. BOOL ViewServicesNode();
  482. HRESULT ToggleDisabled(CDSUINode* pDSUINode, BOOL bDisable);
  483. void AddScopeItemToUI(CUINode* pUINode, BOOL bSetSelected = FALSE);
  484. void AddListOfNodesToUI(CUINode* pUINode, CUINodeList* pNodeList);
  485. HRESULT ReadUINodeFromLdapPath(IN CDSUINode* pContainerDSUINode,
  486. IN LPCWSTR lpszLdapPath,
  487. OUT CDSUINode** ppSUINodeNew);
  488. HRESULT UpdateItem(CUINode* pNode);
  489. private:
  490. HRESULT _OnExpand(CUINode* pNode, HSCOPEITEM hParent, MMC_NOTIFY_TYPE event);
  491. HRESULT _OnPreload(HSCOPEITEM hRoot);
  492. HRESULT BuildDsDisplaySpecOptionsStruct()
  493. {
  494. return m_DsDisplaySpecOptionsCFHolder.Init(GetBasePathsInfo());
  495. }
  496. HRESULT _AddScopeItem(CUINode* pUINode, HSCOPEITEM hParent, BOOL bSetSelected = FALSE);
  497. HRESULT _ChangeRootItemIcon(int nImage);
  498. HRESULT _ChangeResultItemIcon(CUINode* pUINode);
  499. HRESULT _UpdateScopeItem(CUINode* pNode);
  500. // command helpers (called from Command())
  501. HRESULT _CommandNewDSObject(long nCommandID, LPDATAOBJECT pDataObject);
  502. HRESULT _CommandShellExtension(long nCommandID, LPDATAOBJECT pDataObject);
  503. // create object handler
  504. HRESULT _CreateDSObject(IN CDSUINode* pContainerDSUINode,
  505. IN LPCWSTR lpszObjectClass,
  506. IN CDSUINode* pCopyFromSUINode,
  507. OUT CDSUINode** ppSUINodeNew);
  508. // copy object handler
  509. HRESULT _CanCopyDSObject(IDataObject* pCopyFromDsObject);
  510. HRESULT _CopyDSObject(IDataObject* pCopyFromDsObject);
  511. // deletion helpers
  512. HRESULT _DeleteFromBackendAndUI(IDataObject* pDataObject, CDSUINode* pDSUINode);
  513. HRESULT _DeleteFromBackEnd(IDataObject* pDataObject, CDSCookie* pCookie);
  514. public: // expose to other objects
  515. HRESULT ChangeScopeItemIcon(CUINode* pUINode);
  516. HRESULT _DeleteSubtreeFromBackEnd(CDSCookie* pCookie);
  517. HRESULT RemoveContainerFromUI(CUINode* pUINode);
  518. HRESULT SetRenameMode(CUINode* pUINode);
  519. BOOL CanAddCookieToGroup(CDSCookie* pCookie, INT iGroupType, BOOL bMixedMode);
  520. HRESULT SelectScopeNode(CUINode* pUINode);
  521. void SortResultPane(CUINode* pUINode);
  522. CDSColumnSet* FindColumnSet(LPCWSTR lpszColumnID)
  523. {
  524. return (CDSColumnSet*)m_pClassCache->FindColumnSet(lpszColumnID);
  525. }
  526. HRESULT ColumnsChanged(CDSEvent* pDSEvent,
  527. CUINode* pUINode,
  528. MMC_VISIBLE_COLUMNS* pVisibleColumns,
  529. BOOL bRefresh);
  530. void ForceRefreshAll();
  531. HRESULT Refresh(CUINode* pNode, BOOL bFlushCache = FALSE, BOOL bFlushColumns = FALSE);
  532. HRESULT UpdateFromDS(CUINode* pUINode);
  533. BOOL IsSelectionAnywhere(CUINode* pUINode);
  534. // JonN 7/23/99
  535. // 373806: Site&Svcs: Renaming an auto-generated connection should make it admin owned
  536. BOOL RenameConnectionFixup(CDSCookie* pCookie);
  537. void ClearSubtreeHelperForRename(CUINode* pUINode);
  538. CDSCache* GetClassCache() { return m_pClassCache; }
  539. HRESULT FillInChildList(CDSCookie * pCookie);
  540. CDSQueryFilter* GetQueryFilter() { return m_pQueryFilter; }
  541. BOOL IsPrimarySnapin() { return m_bRunAsPrimarySnapin; }
  542. void GetDomain();
  543. void GetDC();
  544. BOOL CanRefreshAll();
  545. void RefreshAll();
  546. void EditFSMO();
  547. void RaiseVersion(void);
  548. CUINode* MoveObjectInUI(CDSUINode* pDSUINode);
  549. HRESULT FindParentCookie(LPCWSTR lpszCookieDN, CUINode** ppParentUINode);
  550. BOOL FindUINodeByDN(CUINode* pContainerNode,
  551. PCWSTR pszDN,
  552. CUINode** ppFoundNode);
  553. void InvalidateSavedQueriesContainingObjects(const CUINodeList& refUINodeList);
  554. void InvalidateSavedQueriesContainingObjects(const CStringList& refPathList);
  555. void SheetLockCookie(CUINode* pNode);
  556. void SheetUnlockCookie(CUINode* pNode);
  557. private:
  558. HRESULT _Rename(CUINode* pNode, LPWSTR NewName);
  559. HRESULT CommitRenameToDS(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  560. HRESULT RenameUser(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  561. HRESULT RenameGroup(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  562. HRESULT RenameNTDSConnection(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  563. HRESULT RenameSubnet(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  564. HRESULT RenameSite(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  565. HRESULT RenameContact(CUINode* pUINode, CDSCookie* pCookie, LPCWSTR NewName);
  566. HRESULT _MoveObject(CDSUINode* pDSUINode);
  567. void ClearClassCacheAndRefreshRoot();
  568. STDMETHOD(_OnPropertyChange)(LPDATAOBJECT pDataObject, BOOL bScope);
  569. BOOL SortChildList (LPWSTR *ppszChildList, UINT cChildCount);
  570. int InsertAtTopContextMenu(LPCWSTR pwszParentClass, LPCWSTR pwszChildClass);
  571. BOOL IsNotHiddenClass (LPWSTR pwszClass, CDSCookie* pParentCookie);
  572. #ifdef FIXUPDC
  573. HRESULT _FixupDC(LPCWSTR pwszPath);
  574. #endif // FIXUPDC
  575. HRESULT _RunKCC(LPCWSTR pwszPath);
  576. // Memory reclamation routines
  577. void ReclaimCookies();
  578. void AddToLRUList (CUINode* pUINode);
  579. // namespace extension API's
  580. HRESULT _OnNamespaceExtensionExpand(LPDATAOBJECT lpDataObject, HSCOPEITEM pParent);
  581. // thread API's
  582. BOOL _StartBackgroundThread();
  583. void _WaitForBackGroundThreadStartAck();
  584. void _ShutDownBackgroundThread();
  585. BOOL _PostQueryToBackgroundThread(CUINode* pUINode);
  586. BOOL _PostMessageToBackgroundThread(UINT Msg, WPARAM wParam, LPARAM lParam);
  587. void _OnTooMuchData(CUINode* pUINode);
  588. void _OnHaveData(CUINode* pUINode, CThreadQueryResult* pResult);
  589. void _OnDone(CUINode* pUINode, HRESULT hr);
  590. void _OnSheetClose(CUINode* pUINode);
  591. void _OnSheetCreate(PDSA_SEC_PAGE_INFO pDsaSecondaryPageInfo);
  592. // sheet API's
  593. BOOL _WarningOnSheetsUp(CUINode* pNode, BOOL bShowMessage = TRUE, BOOL bActivate = TRUE);
  594. BOOL _WarningOnSheetsUp(CInternalFormatCracker* pInternalFormatCracker);
  595. public:
  596. STDMETHOD(QueryFromWorkerThread)(CThreadQueryInfo* pQueryInfo,
  597. CWorkerThread* pWorkerThread);
  598. BOOL CanEnableVerb(CUINode* pUINode);
  599. int GetImage(CUINode* pNode, BOOL bOpen);
  600. UINT GetSerialNumber() {return m_SerialNumber++;}
  601. void Lock() { ::EnterCriticalSection(&m_cs);}
  602. void Unlock() { ::LeaveCriticalSection(&m_cs);}
  603. HWND GetHiddenWindow();
  604. MyBasePathsInfo* GetBasePathsInfo() { return &m_basePathsInfo;}
  605. CDSNotifyHandlerManager* GetNotifyHandlerManager() { return &m_notifyHandlerManager;}
  606. CFavoritesNodesHolder* GetFavoritesNodeHolder() { return m_pFavoritesNodesHolder; }
  607. CTargetingInfo* GetTargetingInfo() { return &m_targetingInfo; }
  608. void SetDirty(BOOL bDirty = TRUE) { m_bDirty = bDirty; }
  609. private:
  610. // InitFunctions
  611. HRESULT _InitRootFromCurrentTargetInfo();
  612. HRESULT _InitRootFromBasePathsInfo(MyBasePathsInfo* pBasePathsInfo);
  613. HRESULT _InitRootFromValidBasePathsInfo();
  614. // JonN 7/18/01 408959/55400
  615. HRESULT _InitFromServerOrDomainName(
  616. MyBasePathsInfo& basePathsInfo,
  617. LPCWSTR lpszServerOrDomain );
  618. private:
  619. CTargetingInfo m_targetingInfo; // manage serialized targeting info
  620. CIconManager m_iconManager; // manage icon strip
  621. MyBasePathsInfo m_basePathsInfo; // container of base path info
  622. CDSNotifyHandlerManager m_notifyHandlerManager;
  623. protected:
  624. CRootNode m_RootNode; // Root node for the snapin
  625. BOOL m_InitSuccess; // successfully contacted DC for naming info?
  626. BOOL m_InitAttempted; // already attempted to contact DC for naming info, don't show errors
  627. CDSDirect* m_ActiveDS;
  628. CDSCache* m_pClassCache;
  629. LPCONSOLENAMESPACE2 m_pScope; // My interface pointer to the scope pane
  630. IConsole3* m_pFrame;
  631. #ifdef _MMC_ISNAPIN_PROPERTY
  632. Properties* m_pProperties; // pointer to MMC properties interface
  633. #endif //_MMC_ISNAPIN_PROPERTY
  634. HWND m_hwnd; // window handle of main window
  635. IImageList* m_pScpImageList;
  636. CStringList m_CreateInfo;
  637. IShellExtInit * m_pShlInit; // Property sheet COM object pointer.
  638. CDsDisplaySpecOptionsCFHolder m_DsDisplaySpecOptionsCFHolder; // cached clipbard format.
  639. UINT m_SerialNumber; // monotonically increasing number used for tracking
  640. // cookies to determine LRU
  641. CUINodeList m_LRUList; // node list for LRU reclamation
  642. BOOL m_bDirty; // dirty flag for serialization on MMC stream
  643. INT m_ColumnWidths[DS_DEFAULT_COLUMN_COUNT]; //save column widths here.
  644. BOOL m_bRunAsPrimarySnapin; // TRUE if the snapin is not an extension
  645. BOOL m_bAddRootWhenExtended; // TRUE adds root node folder
  646. CDSQueryFilter* m_pQueryFilter;
  647. LPCWSTR m_lpszSnapinHelpFile;
  648. CFavoritesNodesHolder* m_pFavoritesNodesHolder;
  649. // thread related variables
  650. private:
  651. CRITICAL_SECTION m_cs;
  652. protected:
  653. void _DeleteHiddenWnd();
  654. CHiddenWnd* m_pHiddenWnd;
  655. CBackgroundThreadInfo* m_pBackgroundThreadInfo; // info about dispatcher thread state
  656. CUINodeQueryTable m_queryNodeTable; // table of cookies having a pending query
  657. // property sheet related variables
  658. private:
  659. CUINodeSheetTable m_sheetNodeTable; // table of cookies having a sheet up
  660. friend class CHiddenWnd; // to access thread notification handlers
  661. };
  662. /////////////////////////////////////////////////////////////////////
  663. // CDSSnapin (DS standalone)
  664. class CDSSnapin:
  665. public CDSComponentData,
  666. public CComCoClass<CDSSnapin, &CLSID_DSSnapin>
  667. {
  668. public:
  669. DECLARE_REGISTRY_CLSID()
  670. //DECLARE_REGISTRY(CDSSnapin, _T("DSSnap.SnapinObj.1"), _T("DSSnap.SnapinObj"), IDS_DSSNAPINNAME, THREADFLAGS_BOTH)
  671. CDSSnapin();
  672. virtual SnapinType QuerySnapinType();
  673. };
  674. /////////////////////////////////////////////////////////////////////
  675. // CDSSnapinEx (DS namespace extension)
  676. class CDSSnapinEx:
  677. public CDSComponentData,
  678. public CComCoClass<CDSSnapinEx, &CLSID_DSSnapinEx>
  679. {
  680. public:
  681. DECLARE_REGISTRY_CLSID()
  682. //DECLARE_REGISTRY(CDSSnapin, _T("DSSnapEx.SnapinObj.1"), _T("DSSnapEx.SnapinObj"), IDS_DSSNAPINNAMEEX, THREADFLAGS_BOTH)
  683. CDSSnapinEx();
  684. virtual SnapinType QuerySnapinType();
  685. };
  686. /////////////////////////////////////////////////////////////////////
  687. // CSiteSnapin (Site manager standalone)
  688. class CSiteSnapin:
  689. public CDSComponentData,
  690. public CComCoClass<CSiteSnapin, &CLSID_SiteSnapin>
  691. {
  692. public:
  693. DECLARE_REGISTRY_CLSID()
  694. //DECLARE_REGISTRY(CSiteSnapin, _T("SiteSnap.SnapinObj.1"), _T("SiteSnap.SnapinObj"), IDS_SITESNAPINNAME, THREADFLAGS_BOTH)
  695. CSiteSnapin();
  696. virtual SnapinType QuerySnapinType();
  697. };
  698. //////////////////////////////////////////////////////////////////////////
  699. // CDSSnapinAbout
  700. class CDSSnapinAbout :
  701. public CSnapinAbout,
  702. public CComCoClass<CDSSnapinAbout, &CLSID_DSAboutSnapin>
  703. {
  704. public:
  705. DECLARE_REGISTRY_CLSID()
  706. CDSSnapinAbout();
  707. };
  708. //////////////////////////////////////////////////////////////////////////
  709. // CSitesSnapinAbout
  710. class CSitesSnapinAbout :
  711. public CSnapinAbout,
  712. public CComCoClass<CSitesSnapinAbout, &CLSID_SitesAboutSnapin>
  713. {
  714. public:
  715. DECLARE_REGISTRY_CLSID()
  716. CSitesSnapinAbout();
  717. };
  718. #endif //__DSSNAP_H__