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.

727 lines
20 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000 - 2001.
  5. //
  6. // File: Rolecont.h
  7. //
  8. // Contents: Class declaration of Base Container class
  9. //
  10. // History: 07-26-2001 Hiteshr Created
  11. //
  12. //----------------------------------------------------------------------------
  13. //forward declarations
  14. class CRolePropertyPageHolder;
  15. class CAdminManagerNode;
  16. /******************************************************************************
  17. Class: CBaseNode
  18. Purpose: This common base class for all snapins node
  19. ******************************************************************************/
  20. class CBaseNode
  21. {
  22. public:
  23. CBaseNode(CRoleComponentDataObject * pComponentDataObject,
  24. CAdminManagerNode* pAdminManagerNode,
  25. CBaseAz* pBaseAz,
  26. BOOL bDeleteBaseAzInDestructor = TRUE);
  27. virtual
  28. ~CBaseNode();
  29. virtual CBaseAz*
  30. GetBaseAzObject()
  31. {
  32. return m_pBaseAz;
  33. }
  34. virtual CSidHandler*
  35. GetSidHandler();
  36. CRoleComponentDataObject*
  37. GetComponentDataObject()
  38. {
  39. return m_pComponentDataObject;
  40. }
  41. CAdminManagerNode*
  42. GetAdminManagerNode()
  43. {
  44. return m_pAdminManagerNode;
  45. }
  46. void
  47. SetComponentDataObject(CRoleComponentDataObject * pComponentDataObject)
  48. {
  49. m_pComponentDataObject = pComponentDataObject;
  50. }
  51. void
  52. SetAdminManagerNode(CAdminManagerNode* pAdminManagerNode)
  53. {
  54. m_pAdminManagerNode = pAdminManagerNode;
  55. }
  56. virtual HRESULT
  57. DeleteAssociatedBaseAzObject();
  58. virtual BOOL
  59. IsNodeDeleteable(){ return TRUE;};
  60. private:
  61. CRoleComponentDataObject * m_pComponentDataObject;
  62. CAdminManagerNode* m_pAdminManagerNode;
  63. CBaseAz* m_pBaseAz;
  64. BOOL m_bDeleteBaseAzInDestructor;
  65. };
  66. /******************************************************************************
  67. Class: CBaseContainerNode
  68. Purpose: This is the base class for snapin nodes which can contain
  69. child nodes.
  70. ******************************************************************************/
  71. class CBaseContainerNode: public CContainerNode, public CBaseNode
  72. {
  73. public:
  74. CBaseContainerNode(CRoleComponentDataObject * pComponentDataObject,
  75. CAdminManagerNode* pAdminManagerNode,
  76. CContainerAz* pContainerAz,
  77. OBJECT_TYPE_AZ* pChildObjectTypes,
  78. LPCONTEXTMENUITEM2 pContextMenu,
  79. BOOL bDeleteBaseAzInDestructor = TRUE);
  80. virtual
  81. ~CBaseContainerNode();
  82. CContainerAz*
  83. GetContainerAzObject(){return (CContainerAz*)GetBaseAzObject();}
  84. protected:
  85. //Get Type/Name/Description
  86. virtual const
  87. CString& GetType() = 0;
  88. virtual const
  89. CString& GetName() = 0;
  90. virtual const
  91. CString& GetDesc() = 0;
  92. virtual void
  93. DoCommand(LONG ,
  94. CComponentDataObject*,
  95. CNodeList*){};
  96. //Helper Functions for enumeration
  97. HRESULT
  98. AddChildNodes();
  99. HRESULT
  100. AddAzCollectionNode(OBJECT_TYPE_AZ eObjectType);
  101. HRESULT
  102. EnumAndAddAzObjectNodes(OBJECT_TYPE_AZ eObjectType);
  103. private:
  104. OBJECT_TYPE_AZ* m_pChildObjectTypes;
  105. LPCONTEXTMENUITEM2 m_pContextMenu;
  106. public:
  107. //
  108. //CTreeNode method overrides
  109. //
  110. virtual HRESULT
  111. GetResultViewType(CComponentDataObject* pComponentData,
  112. LPOLESTR* ppViewType,
  113. long* pViewOptions);
  114. virtual BOOL
  115. OnAddMenuItem(LPCONTEXTMENUITEM2,
  116. long*);
  117. virtual
  118. CColumnSet* GetColumnSet();
  119. virtual LPCWSTR
  120. GetColumnID()
  121. {
  122. return GetColumnSet()->GetColumnID();
  123. }
  124. virtual LPCWSTR
  125. GetString(int nCol);
  126. virtual int
  127. GetImageIndex(BOOL bOpenImage);
  128. //
  129. // Verb handlers
  130. //
  131. virtual void
  132. OnDelete(CComponentDataObject* pComponentData,
  133. CNodeList* pNodeList);
  134. virtual HRESULT
  135. OnCommand(long,
  136. DATA_OBJECT_TYPES,
  137. CComponentDataObject*,
  138. CNodeList*);
  139. virtual BOOL
  140. OnSetRefreshVerbState(DATA_OBJECT_TYPES /*type*/,
  141. BOOL* pbHide,
  142. CNodeList* /*pNodeList*/)
  143. {
  144. *pbHide = FALSE;
  145. return TRUE;
  146. }
  147. LPCONTEXTMENUITEM2
  148. OnGetContextMenuItemTable()
  149. {
  150. return m_pContextMenu;
  151. }
  152. virtual BOOL
  153. OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  154. BOOL* pbHide,
  155. CNodeList* pNodeList);
  156. virtual BOOL
  157. CanCloseSheets();
  158. virtual BOOL
  159. OnEnumerate(CComponentDataObject*,
  160. BOOL bAsync = TRUE);
  161. private:
  162. CColumnSet* m_pColumnSet;
  163. };
  164. /******************************************************************************
  165. Class: CAzContainerNode
  166. Purpose: Snapin Nodes for BaseAz Objects which can contain other child
  167. objects use CAzContainerNode as base class
  168. ******************************************************************************/
  169. class CAzContainerNode: public CBaseContainerNode
  170. {
  171. public:
  172. CAzContainerNode(CRoleComponentDataObject * pComponentDataObject,
  173. CAdminManagerNode* pAdminManagerNode,
  174. OBJECT_TYPE_AZ* pChildObjectTypes,
  175. LPCONTEXTMENUITEM2 pContextMenu,
  176. CContainerAz* pContainerAz);
  177. virtual
  178. ~CAzContainerNode();
  179. protected:
  180. virtual HRESULT
  181. AddOnePageToList(CRolePropertyPageHolder * /*pHolder*/, UINT /*nPageNumber*/)
  182. {
  183. return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS);
  184. }
  185. //Get Type/Name/Description
  186. virtual const CString&
  187. GetType()
  188. {
  189. return GetBaseAzObject()->GetType();
  190. }
  191. virtual const CString&
  192. GetName()
  193. {
  194. return GetBaseAzObject()->GetName();
  195. }
  196. virtual const CString&
  197. GetDesc()
  198. {
  199. return GetBaseAzObject()->GetDescription();
  200. }
  201. private:
  202. public:
  203. virtual BOOL
  204. HasPropertyPages(DATA_OBJECT_TYPES type,
  205. BOOL* pbHideVerb,
  206. CNodeList* pNodeList);
  207. virtual HRESULT
  208. CreatePropertyPages(LPPROPERTYSHEETCALLBACK,
  209. LONG_PTR,
  210. CNodeList*);
  211. virtual void
  212. OnPropertyChange(CComponentDataObject* pComponentData,
  213. BOOL bScopePane,
  214. long changeMask);
  215. };
  216. /******************************************************************************
  217. Class: CCollectionNode
  218. Purpose: Base Class for snapin nodes which are used to group objects of
  219. same type.
  220. ******************************************************************************/
  221. class CCollectionNode: public CBaseContainerNode
  222. {
  223. public:
  224. CCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  225. CAdminManagerNode* pAdminManagerNode,
  226. OBJECT_TYPE_AZ* pChildObjectTypes,
  227. LPCONTEXTMENUITEM2 pContextMenu,
  228. CContainerAz* pContainerAzObject,
  229. UINT nNameStringID,
  230. UINT nTypeStringID,
  231. UINT nDescStringID);
  232. virtual
  233. ~CCollectionNode();
  234. virtual BOOL
  235. IsNodeDeleteable(){ return FALSE;};
  236. virtual int
  237. GetImageIndex(BOOL /*bOpenImage*/)
  238. {
  239. return iIconContainer;
  240. }
  241. protected:
  242. virtual const
  243. CString& GetType(){return m_strType;}
  244. virtual const
  245. CString& GetName(){return m_strName;}
  246. virtual const
  247. CString& GetDesc(){return m_strDesc;}
  248. private:
  249. CString m_strName;
  250. CString m_strType;
  251. CString m_strDesc;
  252. };
  253. //+---------------------------------------------------------------------------
  254. //
  255. // Microsoft Windows
  256. // Copyright (C) Microsoft Corporation, 2000 - 2001.
  257. //
  258. // File: AdminMangerCont.h
  259. //
  260. // Contents:
  261. //
  262. // History: 08-2001 Hiteshr Created
  263. //
  264. //----------------------------------------------------------------------------
  265. //Forward Declarations
  266. class CGroupNode;
  267. class CTaskNode;
  268. class CRoleNode;
  269. class COperationNode;
  270. class CRolePropertyPageHolder;
  271. /******************************************************************************
  272. Class: CAdminManagerNode
  273. Purpose: Snapin Node for AdminManager object
  274. ******************************************************************************/
  275. class CAdminManagerNode : public CAzContainerNode
  276. {
  277. public:
  278. static OBJECT_TYPE_AZ childObjectTypes[];
  279. CAdminManagerNode(CRoleComponentDataObject * pComponentDataObject,
  280. CAdminManagerAz* pAdminManagerAz);
  281. ~CAdminManagerNode();
  282. static HRESULT
  283. CreateFromStream(IN IStream* pStm,
  284. IN CRootData* pRootData,
  285. IN CComponentDataObject * pComponentDataObject);
  286. HRESULT
  287. SaveToStream(IStream* pStm);
  288. const CString&
  289. GetScriptDirectory();
  290. void
  291. SetScriptDirectory(const CString& strScriptDirectory)
  292. {
  293. m_strScriptDirectory = strScriptDirectory;
  294. }
  295. void
  296. DoCommand(LONG nCommandID,
  297. CComponentDataObject*,
  298. CNodeList*);
  299. HRESULT
  300. DeleteAssociatedBaseAzObject();
  301. CSidHandler*
  302. GetSidHandler()
  303. {
  304. return ((CAdminManagerAz*)GetContainerAzObject())->GetSidHandler();
  305. }
  306. virtual const
  307. CString& GetName() { return ((CAdminManagerAz*)GetContainerAzObject())->GetDisplayName();}
  308. DECLARE_NODE_GUID()
  309. protected:
  310. virtual HRESULT
  311. AddOnePageToList(CRolePropertyPageHolder *pHolder,
  312. UINT nPageNumber);
  313. virtual BOOL
  314. OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  315. long *pInsertionAllowed);
  316. private:
  317. CString m_strScriptDirectory;
  318. };
  319. /******************************************************************************
  320. Class: CApplicationNode
  321. Purpose: Snapin Node for Application object
  322. ******************************************************************************/
  323. class CApplicationNode: public CAzContainerNode
  324. {
  325. public:
  326. static OBJECT_TYPE_AZ childObjectTypes[];
  327. CApplicationNode(CRoleComponentDataObject * pComponentDataObject,
  328. CAdminManagerNode* pAdminManagerNode,
  329. CApplicationAz* pApplicationAz);
  330. virtual
  331. ~CApplicationNode();
  332. void
  333. DoCommand(LONG nCommandID,
  334. CComponentDataObject*,
  335. CNodeList*);
  336. DECLARE_NODE_GUID()
  337. protected:
  338. virtual HRESULT
  339. AddOnePageToList(CRolePropertyPageHolder *pHolder,
  340. UINT nPageNumber);
  341. };
  342. /******************************************************************************
  343. Class: CScopeNode
  344. Purpose: Snapin Node for Scope object
  345. ******************************************************************************/
  346. class CScopeNode: public CAzContainerNode
  347. {
  348. public:
  349. static OBJECT_TYPE_AZ childObjectTypes[];
  350. CScopeNode(CRoleComponentDataObject * pComponentDataObject,
  351. CAdminManagerNode* pAdminManagerNode,
  352. CScopeAz* pApplicationAz);
  353. virtual
  354. ~CScopeNode();
  355. DECLARE_NODE_GUID()
  356. protected:
  357. virtual HRESULT
  358. AddOnePageToList(CRolePropertyPageHolder *pHolder,
  359. UINT nPageNumber);
  360. };
  361. /******************************************************************************
  362. Class: CGroupCollectionNode
  363. Purpose: Snapin Node under which all the groups will be listed
  364. ******************************************************************************/
  365. class CGroupCollectionNode:public CCollectionNode
  366. {
  367. public:
  368. static OBJECT_TYPE_AZ childObjectTypes[];
  369. CGroupCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  370. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAzObject);
  371. virtual
  372. ~CGroupCollectionNode();
  373. enum {IDS_NAME = IDS_NAME_GROUP_CONTAINER,
  374. IDS_TYPE = IDS_TYPE_GROUP_CONTAINER,
  375. IDS_DESC = IDS_DESC_GROUP_CONTAINER};
  376. void
  377. DoCommand(LONG nCommandID,
  378. CComponentDataObject*,
  379. CNodeList*);
  380. DECLARE_NODE_GUID()
  381. };
  382. /******************************************************************************
  383. Class: CRoleDefinitionCollectionNode
  384. Purpose: Snapin Node under which all the Role definitions will be listed
  385. ******************************************************************************/
  386. class CRoleDefinitionCollectionNode:public CCollectionNode
  387. {
  388. public:
  389. static OBJECT_TYPE_AZ childObjectTypes[];
  390. CRoleDefinitionCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  391. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAzObject);
  392. virtual
  393. ~CRoleDefinitionCollectionNode();
  394. enum {IDS_NAME = IDS_NAME_ROLE_DEFINITION_CONTAINER,
  395. IDS_TYPE = IDS_TYPE_ROLE_DEFINITION_CONTAINER,
  396. IDS_DESC = IDS_DESC_ROLE_DEFINITION_CONTAINER};
  397. void
  398. DoCommand(LONG nCommandID,
  399. CComponentDataObject*,
  400. CNodeList*);
  401. BOOL
  402. OnEnumerate(CComponentDataObject*, BOOL );
  403. DECLARE_NODE_GUID()
  404. };
  405. /******************************************************************************
  406. Class: CTaskCollectionNode
  407. Purpose: Snapin Node under which all the Tasks will be listed
  408. ******************************************************************************/
  409. class CTaskCollectionNode:public CCollectionNode
  410. {
  411. public:
  412. static OBJECT_TYPE_AZ childObjectTypes[];
  413. CTaskCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  414. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAzObject);
  415. virtual
  416. ~CTaskCollectionNode();
  417. enum {IDS_NAME = IDS_NAME_TASK_CONTAINER,
  418. IDS_TYPE = IDS_TYPE_TASK_CONTAINER,
  419. IDS_DESC = IDS_DESC_TASK_CONTAINER};
  420. void
  421. DoCommand(LONG nCommandID,
  422. CComponentDataObject*,
  423. CNodeList*);
  424. BOOL
  425. OnEnumerate(CComponentDataObject*, BOOL );
  426. DECLARE_NODE_GUID()
  427. };
  428. /******************************************************************************
  429. Class: CRoleCollectionNode
  430. Purpose: Snapin Node under which all the Roles will be listed
  431. ******************************************************************************/
  432. class CRoleCollectionNode:public CCollectionNode
  433. {
  434. public:
  435. static OBJECT_TYPE_AZ childObjectTypes[];
  436. CRoleCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  437. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAzObject);
  438. virtual
  439. ~CRoleCollectionNode();
  440. enum {IDS_NAME = IDS_NAME_ROLE_CONTAINER,
  441. IDS_TYPE = IDS_TYPE_ROLE_CONTAINER,
  442. IDS_DESC = IDS_DESC_ROLE_CONTAINER};
  443. void
  444. DoCommand(LONG nCommandID,
  445. CComponentDataObject*,
  446. CNodeList*);
  447. DECLARE_NODE_GUID()
  448. private:
  449. BOOL
  450. CreateNewRoleObject(CBaseAz* pBaseAz);
  451. };
  452. /******************************************************************************
  453. Class: COperationCollectionNode
  454. Purpose: Snapin Node under which all the Operations will be listed
  455. ******************************************************************************/
  456. class COperationCollectionNode:public CCollectionNode
  457. {
  458. public:
  459. static OBJECT_TYPE_AZ childObjectTypes[];
  460. COperationCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  461. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAzObject);
  462. virtual
  463. ~COperationCollectionNode();
  464. enum {IDS_NAME = IDS_NAME_OPERATION_CONTAINER,
  465. IDS_TYPE = IDS_TYPE_OPERATION_CONTAINER,
  466. IDS_DESC = IDS_DESC_OPERATION_CONTAINER};
  467. VOID
  468. DoCommand(LONG nCommandID,
  469. CComponentDataObject*,
  470. CNodeList*);
  471. DECLARE_NODE_GUID()
  472. };
  473. /******************************************************************************
  474. Class: CDefinitionCollectionNode
  475. Purpose: Snapin Node under which all the Definions nodes will be listed
  476. ******************************************************************************/
  477. class CDefinitionCollectionNode: public CCollectionNode
  478. {
  479. public:
  480. CDefinitionCollectionNode(CRoleComponentDataObject * pComponentDataObject,
  481. CAdminManagerNode* pAdminManagerNode,CContainerAz* pContainerAz);
  482. virtual
  483. ~CDefinitionCollectionNode();
  484. enum {IDS_NAME = IDS_NAME_DEFINITION_CONTAINER,
  485. IDS_TYPE = IDS_TYPE_DEFINITION_CONTAINER,
  486. IDS_DESC = IDS_DESC_DEFINITION_CONTAINER};
  487. BOOL
  488. OnEnumerate(CComponentDataObject*, BOOL bAsync = TRUE);
  489. DECLARE_NODE_GUID()
  490. };
  491. /******************************************************************************
  492. Class: CRoleNode
  493. Purpose: Snapin Node for RoleAz object
  494. ******************************************************************************/
  495. class CRoleNode:public CContainerNode, public CBaseNode
  496. {
  497. public:
  498. CRoleNode(CRoleComponentDataObject * pComponentDataObject,
  499. CAdminManagerNode* pAdminManagerNode,
  500. CRoleAz* pRoleAz);
  501. virtual
  502. ~CRoleNode();
  503. //CTreeNode method overrides
  504. virtual HRESULT
  505. GetResultViewType(CComponentDataObject* pComponentData,
  506. LPOLESTR* ppViewType,
  507. long* pViewOptions);
  508. virtual BOOL
  509. OnAddMenuItem(LPCONTEXTMENUITEM2,long*);
  510. virtual CColumnSet*
  511. GetColumnSet();
  512. virtual LPCWSTR
  513. GetColumnID(){return GetColumnSet()->GetColumnID();}
  514. virtual LPCWSTR
  515. GetString(int nCol);
  516. virtual int
  517. GetImageIndex(BOOL bOpenImage);
  518. // Verb handlers
  519. BOOL
  520. OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  521. BOOL* pbHide,
  522. CNodeList* pNodeList);
  523. virtual void
  524. OnDelete(CComponentDataObject* pComponentData,
  525. CNodeList* pNodeList);
  526. virtual HRESULT
  527. OnCommand(long,
  528. DATA_OBJECT_TYPES,
  529. CComponentDataObject*,
  530. CNodeList*);
  531. virtual BOOL
  532. OnSetRefreshVerbState(DATA_OBJECT_TYPES /*type*/,
  533. BOOL* pbHide,
  534. CNodeList* /*pNodeList*/)
  535. {
  536. *pbHide = FALSE;
  537. return TRUE;
  538. }
  539. LPCONTEXTMENUITEM2
  540. OnGetContextMenuItemTable()
  541. {
  542. return CRoleNodeMenuHolder::GetContextMenuItem();
  543. }
  544. virtual BOOL
  545. OnEnumerate(CComponentDataObject*,
  546. BOOL bAsync = TRUE);
  547. BOOL
  548. HasPropertyPages(DATA_OBJECT_TYPES /*type*/,
  549. BOOL* pbHideVerb,
  550. CNodeList* pNodeList);
  551. HRESULT
  552. CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  553. LONG_PTR handle,
  554. CNodeList* pNodeList);
  555. void
  556. OnPropertyChange(CComponentDataObject* pComponentData,
  557. BOOL bScopePane,
  558. long changeMask);
  559. DECLARE_NODE_GUID()
  560. private:
  561. void
  562. AssignUsersAndGroups(IN CComponentDataObject* pComponentData,
  563. IN ULONG nCommandID);
  564. void
  565. AddObjectsFromListToSnapin(CList<CBaseAz*,CBaseAz*> &listObjects,
  566. CComponentDataObject* pComponentData,
  567. BOOL bAddToUI);
  568. CColumnSet* m_pColumnSet;
  569. };
  570. void
  571. GenericDeleteRoutine(CBaseNode* pBaseNode,
  572. CComponentDataObject* pComponentData,
  573. CNodeList* pNodeList,
  574. BOOL bConfirmDelete);