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.

1044 lines
24 KiB

  1. // cacls.cpp: implementation of the CADsAccessControlEntry class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "objects.h"
  6. #include "maindoc.h"
  7. #include "cacls.h"
  8. #include "newquery.h"
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[]=__FILE__;
  12. #define new DEBUG_NEW
  13. #endif
  14. //////////////////////////////////////////////////////////////////////
  15. // Construction/Destruction
  16. //////////////////////////////////////////////////////////////////////
  17. //***********************************************************
  18. // Function:
  19. // Arguments:
  20. // Return:
  21. // Purpose:
  22. // Author(s):
  23. // Revision:
  24. // Date:
  25. //***********************************************************
  26. //***********************************************************
  27. // Function:
  28. // Arguments:
  29. // Return:
  30. // Purpose:
  31. // Author(s):
  32. // Revision:
  33. // Date:
  34. //***********************************************************
  35. CADsAccessControlEntry::CADsAccessControlEntry()
  36. {
  37. InitializeMembers( );
  38. }
  39. //***********************************************************
  40. // Function:
  41. // Arguments:
  42. // Return:
  43. // Purpose:
  44. // Author(s):
  45. // Revision:
  46. // Date:
  47. //***********************************************************
  48. CADsAccessControlEntry::CADsAccessControlEntry( IUnknown* pIUnk)
  49. :COleDsObject( pIUnk )
  50. {
  51. InitializeMembers( );
  52. }
  53. //***********************************************************
  54. // Function:
  55. // Arguments:
  56. // Return:
  57. // Purpose:
  58. // Author(s):
  59. // Revision:
  60. // Date:
  61. //***********************************************************
  62. CADsAccessControlEntry::~CADsAccessControlEntry( )
  63. {
  64. }
  65. //***********************************************************
  66. // Function: CADsAccessControlEntry::PutProperty
  67. // Arguments:
  68. // Return:
  69. // Purpose:
  70. // Author(s):
  71. // Revision:
  72. // Date:
  73. //***********************************************************
  74. HRESULT CADsAccessControlEntry::PutProperty ( int nProp,
  75. CString& rValue,
  76. long lCode )
  77. {
  78. BOOL bOldUseGeneric;
  79. HRESULT hResult;
  80. bOldUseGeneric = m_pDoc->GetUseGeneric( );
  81. m_pDoc->SetUseGeneric( FALSE );
  82. hResult = COleDsObject::PutProperty( nProp, rValue, lCode );
  83. m_pDoc->SetUseGeneric( bOldUseGeneric );
  84. return hResult;
  85. }
  86. //***********************************************************
  87. // Function:
  88. // Arguments:
  89. // Return:
  90. // Purpose:
  91. // Author(s):
  92. // Revision:
  93. // Date:
  94. //***********************************************************
  95. HRESULT CADsAccessControlEntry::GetProperty ( int nProp,
  96. CString& rValue )
  97. {
  98. BOOL bOldUseGeneric;
  99. HRESULT hResult;
  100. bOldUseGeneric = m_pDoc->GetUseGeneric( );
  101. m_pDoc->SetUseGeneric( FALSE );
  102. hResult = COleDsObject::GetProperty( nProp, rValue );
  103. m_pDoc->SetUseGeneric( bOldUseGeneric );
  104. return hResult;
  105. }
  106. //***********************************************************
  107. // Function:
  108. // Arguments:
  109. // Return:
  110. // Purpose:
  111. // Author(s):
  112. // Revision:
  113. // Date:
  114. //***********************************************************
  115. IDispatch* CADsAccessControlEntry::GetACE( )
  116. {
  117. IDispatch* pDispatch = NULL;
  118. if( NULL != m_pIUnk )
  119. {
  120. m_pIUnk->QueryInterface( IID_IDispatch, (void**)&pDispatch );
  121. }
  122. return pDispatch;
  123. }
  124. //***********************************************************
  125. // Function:
  126. // Arguments:
  127. // Return:
  128. // Purpose:
  129. // Author(s):
  130. // Revision:
  131. // Date:
  132. //***********************************************************
  133. IDispatch* CADsAccessControlEntry::CreateACE( )
  134. {
  135. IDispatch* pDispatch = NULL;
  136. IADsAccessControlEntry* pNewACE = NULL;
  137. HRESULT hResult = NULL;
  138. DWORD dwAceType = 0;
  139. CACEDialog aDialog;
  140. BSTR bstrTrustee;
  141. if( IDOK != aDialog.DoModal( ) )
  142. return NULL;
  143. hResult = CoCreateInstance(
  144. CLSID_AccessControlEntry,
  145. NULL,
  146. CLSCTX_INPROC_SERVER,
  147. IID_IADsAccessControlEntry,
  148. (void **)&pNewACE
  149. );
  150. if( SUCCEEDED( hResult ) )
  151. {
  152. bstrTrustee = AllocBSTR( aDialog.m_strTrustee.GetBuffer( 128 ) );
  153. pNewACE->put_Trustee( bstrTrustee );
  154. hResult = pNewACE->QueryInterface( IID_IDispatch,
  155. (void**)&pDispatch );
  156. SysFreeString( bstrTrustee );
  157. pNewACE->Release( );
  158. }
  159. return pDispatch;
  160. return NULL;
  161. }
  162. //***********************************************************
  163. // Function:
  164. // Arguments:
  165. // Return:
  166. // Purpose:
  167. // Author(s):
  168. // Revision:
  169. // Date:
  170. //***********************************************************
  171. void CADsAccessControlEntry::InitializeMembers ( )
  172. {
  173. IADsAccessControlEntry* pEntry;
  174. HRESULT hResult;
  175. if( NULL != m_pIUnk )
  176. {
  177. hResult = m_pIUnk->QueryInterface( IID_IADsAccessControlEntry,
  178. (void**)&pEntry );
  179. if( SUCCEEDED( hResult ) )
  180. {
  181. BSTR bstrTrustee = NULL;
  182. TCHAR szTrustee[ 256 ];
  183. pEntry->get_Trustee( &bstrTrustee );
  184. if( NULL != bstrTrustee )
  185. {
  186. Convert( szTrustee, bstrTrustee );
  187. m_strItemName = szTrustee;
  188. }
  189. SysFreeString( bstrTrustee );
  190. pEntry->Release( );
  191. }
  192. }
  193. m_strSchemaPath = _T("ACE");
  194. }
  195. //***********************************************************
  196. // Function:
  197. // Arguments:
  198. // Return:
  199. // Purpose:
  200. // Author(s):
  201. // Revision:
  202. // Date:
  203. //***********************************************************
  204. CADsSecurityDescriptor::CADsSecurityDescriptor()
  205. {
  206. InitializeMembers( );
  207. }
  208. //***********************************************************
  209. // Function:
  210. // Arguments:
  211. // Return:
  212. // Purpose:
  213. // Author(s):
  214. // Revision:
  215. // Date:
  216. //***********************************************************
  217. CADsSecurityDescriptor::CADsSecurityDescriptor( IUnknown* pIUnk )
  218. :COleDsObject( pIUnk )
  219. {
  220. /*IADsSecurityDescriptor* pSecD;
  221. IDispatch* pCopy;
  222. HRESULT hResult;
  223. hResult = m_pIUnk->QueryInterface( IID_IADsSecurityDescriptor,
  224. (void**)&pSecD );
  225. hResult = pSecD->CopySecurityDescriptor( &pCopy );
  226. if( SUCCEEDED( hResult ) )
  227. {
  228. m_pIUnk->Release( );
  229. hResult = pCopy->QueryInterface( IID_IUnknown,(void**)&m_pIUnk );
  230. pCopy->Release( );
  231. }
  232. pSecD->Release( );*/
  233. InitializeMembers( );
  234. }
  235. //***********************************************************
  236. // Function:
  237. // Arguments:
  238. // Return:
  239. // Purpose:
  240. // Author(s):
  241. // Revision:
  242. // Date:
  243. //***********************************************************
  244. CADsSecurityDescriptor::~CADsSecurityDescriptor()
  245. {
  246. for( int nIdx = 0; nIdx < (int) acl_Limit ; nIdx++ )
  247. {
  248. if( NULL != pACLObj[ nIdx ] )
  249. delete pACLObj[ nIdx ];
  250. }
  251. }
  252. //***********************************************************
  253. // Function:
  254. // Arguments:
  255. // Return:
  256. // Purpose:
  257. // Author(s):
  258. // Revision:
  259. // Date:
  260. //***********************************************************
  261. HRESULT CADsSecurityDescriptor::PutProperty ( int nProp,
  262. CString& rValue,
  263. long lCode )
  264. {
  265. BOOL bOldUseGeneric;
  266. HRESULT hResult;
  267. bOldUseGeneric = m_pDoc->GetUseGeneric( );
  268. m_pDoc->SetUseGeneric( FALSE );
  269. hResult = COleDsObject::PutProperty( nProp, rValue, lCode );
  270. m_pDoc->SetUseGeneric( bOldUseGeneric );
  271. return hResult;
  272. }
  273. //***********************************************************
  274. // Function:
  275. // Arguments:
  276. // Return:
  277. // Purpose:
  278. // Author(s):
  279. // Revision:
  280. // Date:
  281. //***********************************************************
  282. HRESULT CADsSecurityDescriptor::GetProperty ( int nProp,
  283. CString& rValue )
  284. {
  285. BOOL bOldUseGeneric;
  286. HRESULT hResult;
  287. bOldUseGeneric = m_pDoc->GetUseGeneric( );
  288. m_pDoc->SetUseGeneric( FALSE );
  289. hResult = COleDsObject::GetProperty( nProp, rValue );
  290. m_pDoc->SetUseGeneric( bOldUseGeneric );
  291. return hResult;
  292. }
  293. //***********************************************************
  294. // Function:
  295. // Arguments:
  296. // Return:
  297. // Purpose:
  298. // Author(s):
  299. // Revision:
  300. // Date:
  301. //***********************************************************
  302. void CADsSecurityDescriptor::InitializeMembers ( )
  303. {
  304. HRESULT hResult;
  305. IADsSecurityDescriptor* pDescriptor = NULL;
  306. IDispatch* pDispACL;
  307. m_strSchemaPath = _T("SecurityDescriptor");
  308. pACLObj[ acl_SACL ] = NULL;
  309. pACLObj[ acl_DACL ] = NULL;
  310. pACLObj[ acl_Invalid ] = NULL;
  311. if( NULL == m_pIUnk )
  312. return;
  313. while( TRUE )
  314. {
  315. hResult = m_pIUnk->QueryInterface( IID_IADsSecurityDescriptor,
  316. (void**)&pDescriptor );
  317. ASSERT( SUCCEEDED( hResult ) );
  318. if( FAILED( hResult ) )
  319. break;
  320. pDispACL = GetACL( acl_DACL );
  321. ASSERT( NULL != pDispACL );
  322. if( NULL != pDispACL )
  323. {
  324. pACLObj[ acl_DACL ] = new CADsAccessControlList( pDispACL );
  325. pDispACL->Release( );
  326. }
  327. pDispACL = GetACL( acl_SACL );
  328. ASSERT( NULL != pDispACL );
  329. if( NULL != pDispACL )
  330. {
  331. pACLObj[ acl_SACL ] = new CADsAccessControlList( pDispACL );
  332. pDispACL->Release( );
  333. }
  334. break;
  335. }
  336. if( NULL != pDescriptor )
  337. {
  338. pDescriptor->Release( );
  339. }
  340. }
  341. //***********************************************************
  342. // Function:
  343. // Arguments:
  344. // Return:
  345. // Purpose:
  346. // Author(s):
  347. // Revision:
  348. // Date:
  349. //***********************************************************
  350. IDispatch* CADsSecurityDescriptor::GetACL( ACLTYPE eType )
  351. {
  352. HRESULT hResult;
  353. IDispatch* pACL = NULL;
  354. IDispatch* pCopyACL = NULL;
  355. IADsSecurityDescriptor* pSecDescr = NULL;
  356. while( TRUE )
  357. {
  358. if( NULL == m_pIUnk )
  359. break;
  360. //QI for IID_IADsSecurityDescriptor interface
  361. hResult = m_pIUnk->QueryInterface( IID_IADsSecurityDescriptor,
  362. (void**)&pSecDescr );
  363. ASSERT( SUCCEEDED( hResult ) );
  364. if( FAILED( hResult ) )
  365. {
  366. break;
  367. }
  368. hResult = E_FAIL;
  369. if( acl_DACL == eType )
  370. {
  371. hResult = pSecDescr->get_DiscretionaryAcl( &pACL );
  372. }
  373. if( acl_SACL == eType )
  374. {
  375. hResult = pSecDescr->get_SystemAcl( &pACL );
  376. }
  377. pSecDescr->Release( );
  378. ASSERT( SUCCEEDED( hResult ) );
  379. break;
  380. }
  381. if( NULL != pACL )
  382. {
  383. //pCopyACL = CopyACL( pACL );
  384. //pACL->Release( );
  385. pACL->QueryInterface( IID_IDispatch, (void**)&pCopyACL );
  386. pACL->Release( );
  387. }
  388. return pCopyACL;
  389. }
  390. //***********************************************************
  391. // Function:
  392. // Arguments:
  393. // Return:
  394. // Purpose:
  395. // Author(s):
  396. // Revision:
  397. // Date:
  398. //***********************************************************
  399. HRESULT CADsSecurityDescriptor::PutACL( IDispatch * pACL,
  400. ACLTYPE eACL )
  401. {
  402. HRESULT hResult;
  403. IADsSecurityDescriptor* pSecDescr = NULL;
  404. while( TRUE )
  405. {
  406. if( NULL == m_pIUnk )
  407. break;
  408. //QI for IID_IADsSecurityDescriptor interface
  409. hResult = m_pIUnk->QueryInterface( IID_IADsSecurityDescriptor,
  410. (void**)&pSecDescr );
  411. ASSERT( SUCCEEDED( hResult ) );
  412. if( FAILED( hResult ) )
  413. {
  414. break;
  415. }
  416. hResult = E_FAIL;
  417. if( acl_DACL == eACL )
  418. {
  419. hResult = pSecDescr->put_DiscretionaryAcl( pACL );
  420. }
  421. if( acl_SACL == eACL )
  422. {
  423. hResult = pSecDescr->put_SystemAcl( pACL );
  424. }
  425. pSecDescr->Release( );
  426. break;
  427. }
  428. return hResult;
  429. }
  430. //***********************************************************
  431. // Function:
  432. // Arguments:
  433. // Return:
  434. // Purpose:
  435. // Author(s):
  436. // Revision:
  437. // Date:
  438. //***********************************************************
  439. HRESULT CADsSecurityDescriptor::AddACE( ACLTYPE eACL, IUnknown* pNewACE )
  440. {
  441. ASSERT( acl_DACL == eACL || acl_SACL == eACL );
  442. if( acl_DACL != eACL && acl_SACL != eACL )
  443. return -1;
  444. if( NULL == pACLObj[ (int)eACL ] )
  445. return -1;
  446. return ((CADsAccessControlList*)(pACLObj[ (int)eACL ]))->AddACE( pNewACE );
  447. }
  448. //***********************************************************
  449. // Function:
  450. // Arguments:
  451. // Return:
  452. // Purpose:
  453. // Author(s):
  454. // Revision:
  455. // Date:
  456. //***********************************************************
  457. HRESULT CADsSecurityDescriptor::RemoveACE( ACLTYPE eACL, IUnknown* pRemoveACE )
  458. {
  459. ASSERT( acl_DACL == eACL || acl_SACL == eACL );
  460. if( acl_DACL != eACL && acl_SACL != eACL )
  461. return -1;
  462. if( NULL == pACLObj[ (int)eACL ] )
  463. return -1;
  464. return ((CADsAccessControlList*)(pACLObj[ (int)eACL ]))->RemoveACE( pRemoveACE );
  465. }
  466. //***********************************************************
  467. // Function:
  468. // Arguments:
  469. // Return:
  470. // Purpose:
  471. // Author(s):
  472. // Revision:
  473. // Date:
  474. //***********************************************************
  475. void CADsSecurityDescriptor::SetDocument( CMainDoc* pDoc )
  476. {
  477. int nIdx;
  478. COleDsObject::SetDocument ( pDoc );
  479. for( nIdx = 0 ; nIdx < (int)acl_Limit ; nIdx++ )
  480. {
  481. if( NULL != pACLObj[ nIdx ] )
  482. pACLObj[ nIdx ]->SetDocument( pDoc );
  483. }
  484. }
  485. //***********************************************************
  486. // Function:
  487. // Arguments:
  488. // Return:
  489. // Purpose:
  490. // Author(s):
  491. // Revision:
  492. // Date:
  493. //***********************************************************
  494. void CADsSecurityDescriptor::RemoveAllACE( ACLTYPE eACL )
  495. {
  496. ASSERT( acl_DACL == eACL || acl_SACL == eACL );
  497. if( acl_DACL != eACL && acl_SACL != eACL )
  498. return;
  499. if( NULL == pACLObj[ (int)eACL ] )
  500. return;
  501. }
  502. //***********************************************************
  503. // Function:
  504. // Arguments:
  505. // Return:
  506. // Purpose:
  507. // Author(s):
  508. // Revision:
  509. // Date:
  510. //***********************************************************
  511. CADsAccessControlList* CADsSecurityDescriptor::GetACLObject( ACLTYPE eACL )
  512. {
  513. CADsAccessControlList* pACL;
  514. ASSERT( acl_DACL == eACL || acl_SACL == eACL );
  515. if( acl_DACL != eACL && acl_SACL != eACL )
  516. return NULL;
  517. pACL = (CADsAccessControlList*) (pACLObj[ (int)eACL ]);
  518. return pACL;
  519. }
  520. //***********************************************************
  521. // Function:
  522. // Arguments:
  523. // Return:
  524. // Purpose:
  525. // Author(s):
  526. // Revision:
  527. // Date:
  528. //***********************************************************
  529. CADsAccessControlList::CADsAccessControlList()
  530. {
  531. InitializeMembers( );
  532. }
  533. //***********************************************************
  534. // Function:
  535. // Arguments:
  536. // Return:
  537. // Purpose:
  538. // Author(s):
  539. // Revision:
  540. // Date:
  541. //***********************************************************
  542. CADsAccessControlList::CADsAccessControlList( IUnknown* pUnk ):
  543. COleDsObject( pUnk )
  544. {
  545. InitializeMembers( );
  546. }
  547. //***********************************************************
  548. // Function: CADsAccessControlList::AddACE
  549. // Arguments:
  550. // Return:
  551. // Purpose:
  552. // Author(s):
  553. // Revision:
  554. // Date:
  555. //***********************************************************
  556. HRESULT CADsAccessControlList::AddACE( IUnknown* pNewACE )
  557. {
  558. IDispatch* pDisp = NULL;
  559. HRESULT hResult;
  560. IADsAccessControlList* pACL = NULL;
  561. if( NULL == m_pIUnk )
  562. {
  563. return E_FAIL;
  564. }
  565. hResult = m_pIUnk->QueryInterface( IID_IADsAccessControlList,
  566. (void**)&pACL );
  567. if( FAILED( hResult ) )
  568. return hResult;
  569. hResult = pNewACE->QueryInterface( IID_IDispatch, (void**)&pDisp );
  570. if( SUCCEEDED( hResult ) )
  571. {
  572. hResult = pACL->AddAce( pDisp );
  573. if( SUCCEEDED( hResult ) )
  574. InitializeMembers( );
  575. pDisp->Release( );
  576. }
  577. pACL->Release( );
  578. return hResult;
  579. }
  580. //***********************************************************
  581. // Function: CADsAccessControlList::AddACE
  582. // Arguments:
  583. // Return:
  584. // Purpose:
  585. // Author(s):
  586. // Revision:
  587. // Date:
  588. //***********************************************************
  589. HRESULT CADsAccessControlList::RemoveACE( IUnknown* pRemoveACE )
  590. {
  591. IDispatch* pDisp = NULL;
  592. HRESULT hResult;
  593. IADsAccessControlList* pACL = NULL;
  594. if( NULL == m_pIUnk )
  595. {
  596. return E_FAIL;
  597. }
  598. hResult = m_pIUnk->QueryInterface( IID_IADsAccessControlList,
  599. (void**)&pACL );
  600. if( FAILED( hResult ) )
  601. return hResult;
  602. hResult = pRemoveACE->QueryInterface( IID_IDispatch, (void**)&pDisp );
  603. if( SUCCEEDED( hResult ) )
  604. {
  605. hResult = pACL->RemoveAce( pDisp );
  606. if( SUCCEEDED( hResult ) )
  607. InitializeMembers( );
  608. pDisp->Release( );
  609. }
  610. pACL->Release( );
  611. return hResult;
  612. }
  613. //***********************************************************
  614. // Function: CADsAccessControlList::~CADsAccessControlList
  615. // Arguments:
  616. // Return:
  617. // Purpose:
  618. // Author(s):
  619. // Revision:
  620. // Date:
  621. //***********************************************************
  622. CADsAccessControlList::~CADsAccessControlList()
  623. {
  624. for( int nIdx = 0 ; nIdx < m_arrACE.GetSize( ) ; nIdx++ )
  625. {
  626. delete m_arrACE.GetAt( nIdx );
  627. }
  628. m_arrACE.RemoveAll( );
  629. }
  630. //***********************************************************
  631. // Function: CADsAccessControlList::GetACL
  632. // Arguments:
  633. // Return:
  634. // Purpose:
  635. // Author(s):
  636. // Revision:
  637. // Date:
  638. //***********************************************************
  639. IDispatch* CADsAccessControlList::GetACL( )
  640. {
  641. IDispatch* pDispatch = NULL;
  642. if( NULL != m_pIUnk )
  643. {
  644. m_pIUnk->QueryInterface( IID_IDispatch, (void**)&pDispatch );
  645. }
  646. return pDispatch;
  647. }
  648. //***********************************************************
  649. // Function:
  650. // Arguments:
  651. // Return:
  652. // Purpose:
  653. // Author(s):
  654. // Revision:
  655. // Date:
  656. //***********************************************************
  657. IDispatch* CADsAccessControlList::CreateACL( )
  658. {
  659. IDispatch* pDispatch = NULL;
  660. IADsAccessControlList* pNewACL = NULL;
  661. HRESULT hResult = NULL;
  662. DWORD dwAceType = 0;
  663. hResult = CoCreateInstance(
  664. CLSID_AccessControlList,
  665. NULL,
  666. CLSCTX_INPROC_SERVER,
  667. IID_IADsAccessControlList,
  668. (void **)&pNewACL
  669. );
  670. if( SUCCEEDED( hResult ) )
  671. {
  672. hResult = pNewACL->QueryInterface( IID_IDispatch,
  673. (void**)&pDispatch );
  674. pNewACL->Release( );
  675. }
  676. return pDispatch;
  677. }
  678. //***********************************************************
  679. // Function: CADsAccessControlList::PutProperty
  680. // Arguments:
  681. // Return:
  682. // Purpose:
  683. // Author(s):
  684. // Revision:
  685. // Date:
  686. //***********************************************************
  687. HRESULT CADsAccessControlList::PutProperty ( int nACE,
  688. int nProp,
  689. CString& rVal,
  690. long lCode )
  691. {
  692. HRESULT hResult;
  693. COleDsObject* pACE;
  694. ASSERT( nACE < m_arrACE.GetSize( ) );
  695. if( nACE < m_arrACE.GetSize( ) )
  696. {
  697. pACE = (COleDsObject*) m_arrACE.GetAt( nACE );
  698. hResult = pACE->PutProperty ( nProp, rVal, lCode );
  699. }
  700. return hResult;
  701. }
  702. //***********************************************************
  703. // Function: CADsAccessControlList::GetProperty
  704. // Arguments:
  705. // Return:
  706. // Purpose:
  707. // Author(s):
  708. // Revision:
  709. // Date:
  710. //***********************************************************
  711. HRESULT CADsAccessControlList::GetProperty ( int nACE,
  712. int nProp,
  713. CString& rVal )
  714. {
  715. HRESULT hResult;
  716. COleDsObject* pACE;
  717. ASSERT( nACE < m_arrACE.GetSize( ) );
  718. if( nACE < m_arrACE.GetSize( ) )
  719. {
  720. pACE = (COleDsObject*) m_arrACE.GetAt( nACE );
  721. hResult = pACE->GetProperty ( nProp, rVal );
  722. }
  723. return hResult;
  724. }
  725. //***********************************************************
  726. // Function: CADsAccessControlList::InitializeMembers
  727. // Arguments:
  728. // Return:
  729. // Purpose:
  730. // Author(s):
  731. // Revision:
  732. // Date:
  733. //***********************************************************
  734. void CADsAccessControlList::InitializeMembers( )
  735. {
  736. IADsAccessControlList* pACList = NULL;
  737. IUnknown* pIUnk;
  738. HRESULT hResult;
  739. IEnumVARIANT* pEnum = NULL;
  740. VARIANT aVariant;
  741. IUnknown* pACE;
  742. ULONG ulGet;
  743. if( !m_pIUnk )
  744. return;
  745. for( int nIdx = 0 ; nIdx < m_arrACE.GetSize( ) ; nIdx++ )
  746. {
  747. delete m_arrACE.GetAt( nIdx );
  748. }
  749. m_arrACE.RemoveAll( );
  750. while( TRUE )
  751. {
  752. //hResult = m_pIUnk->QueryInterface( IID_IEnumVARIANT,
  753. // (void**)&pEnum );
  754. hResult = m_pIUnk->QueryInterface( IID_IADsAccessControlList,
  755. (void**)&pACList );
  756. ASSERT( SUCCEEDED( hResult ) );
  757. if( FAILED( hResult ) )
  758. break;
  759. hResult = pACList->get__NewEnum( &pIUnk );
  760. ASSERT( SUCCEEDED( hResult ) );
  761. if( FAILED( hResult ) )
  762. break;
  763. hResult = pIUnk->QueryInterface( IID_IEnumVARIANT,
  764. (void**)&pEnum );
  765. pIUnk->Release( );
  766. pACList->Release( );
  767. ASSERT( SUCCEEDED( hResult ) );
  768. if( FAILED( hResult ) )
  769. break;
  770. while( TRUE )
  771. {
  772. CADsAccessControlEntry* pNewACE;
  773. ulGet = 0L;
  774. hResult = pEnum->Next( 1, &aVariant, &ulGet );
  775. if( FAILED( hResult ) )
  776. break;
  777. if( 0 == ulGet )
  778. break;
  779. hResult = V_DISPATCH( &aVariant )->QueryInterface( IID_IUnknown,
  780. (void**)&pACE );
  781. VariantClear( &aVariant );
  782. pNewACE = new CADsAccessControlEntry( pACE );
  783. if( NULL != m_pDoc )
  784. {
  785. pNewACE->SetDocument( m_pDoc );
  786. }
  787. m_arrACE.Add( pNewACE );
  788. pACE->Release( );
  789. }
  790. pEnum->Release( );
  791. break;
  792. }
  793. }
  794. //***********************************************************
  795. // Function:
  796. // Arguments:
  797. // Return:
  798. // Purpose:
  799. // Author(s):
  800. // Revision:
  801. // Date:
  802. //***********************************************************
  803. void CADsAccessControlList::SetDocument ( CMainDoc* pDoc )
  804. {
  805. COleDsObject* pObject;
  806. int nSize, nIdx;
  807. COleDsObject::SetDocument ( pDoc );
  808. nSize = (int)m_arrACE.GetSize( );
  809. for( nIdx = 0; nIdx < nSize ; nIdx++ )
  810. {
  811. pObject = (COleDsObject*)m_arrACE.GetAt( nIdx );
  812. pObject->SetDocument( pDoc );
  813. }
  814. }
  815. //***********************************************************
  816. // Function: CADsAccessControlList::GetACECount
  817. // Arguments:
  818. // Return:
  819. // Purpose:
  820. // Author(s):
  821. // Revision:
  822. // Date:
  823. //***********************************************************
  824. int CADsAccessControlList::GetACECount ( void )
  825. {
  826. return (int)m_arrACE.GetSize( );
  827. }
  828. //***********************************************************
  829. // Function: CADsAccessControlList::GetACEObject
  830. // Arguments:
  831. // Return:
  832. // Purpose:
  833. // Author(s):
  834. // Revision:
  835. // Date:
  836. //***********************************************************
  837. CADsAccessControlEntry* CADsAccessControlList::GetACEObject ( int nACE )
  838. {
  839. CADsAccessControlEntry* pACE;
  840. //ASSERT( nACE < GetACECount( ) );
  841. if( nACE >= GetACECount( ) )
  842. return NULL;
  843. pACE = (CADsAccessControlEntry*) (m_arrACE.GetAt( nACE ) );
  844. return pACE;
  845. }
  846.