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.

778 lines
22 KiB

  1. /*****************************************************************************/
  2. /* Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved /
  3. /*****************************************************************************/
  4. /*
  5. * CAccessEntry.cpp - implementation file for CAccessEntry class.
  6. *
  7. * Created: 12-14-1997 by Sanjeev Surati
  8. * (based on classes from Windows NT Security by Nik Okuntseff)
  9. */
  10. #include "precomp.h"
  11. #include <assertbreak.h>
  12. #include "AccessEntry.h"
  13. #include <accctrl.h>
  14. #include "wbemnetapi32.h"
  15. #include "SecUtils.h"
  16. ///////////////////////////////////////////////////////////////////
  17. //
  18. // Function: CAccessEntry::CAccessEntry
  19. //
  20. // Default class constructor.
  21. //
  22. // Inputs:
  23. // None.
  24. //
  25. // Outputs:
  26. // None.
  27. //
  28. // Returns:
  29. // None.
  30. //
  31. // Comments:
  32. //
  33. ///////////////////////////////////////////////////////////////////
  34. CAccessEntry::CAccessEntry( void )
  35. : m_Sid(),
  36. m_bACEType( 0 ),
  37. m_bACEFlags( 0 ),
  38. m_dwAccessMask( 0 ),
  39. m_pguidObjType(NULL),
  40. m_pguidInhObjType(NULL)
  41. {
  42. }
  43. ///////////////////////////////////////////////////////////////////
  44. //
  45. // Function: CAccessEntry::CAccessEntry
  46. //
  47. // Class constructor.
  48. //
  49. // Inputs:
  50. // PSID pSid - Sid to intialize from
  51. // BYTE bACEType - ACE Type
  52. // BYTE bACEFlags - Flags.
  53. // DWORD dwAccessMask - Access Mask
  54. // char* pszComputerName - Computer name to
  55. // init SID from.
  56. //
  57. // Outputs:
  58. // None.
  59. //
  60. // Returns:
  61. // None.
  62. //
  63. // Comments:
  64. //
  65. ///////////////////////////////////////////////////////////////////
  66. CAccessEntry::CAccessEntry( PSID pSid,
  67. BYTE bACEType,
  68. BYTE bACEFlags,
  69. GUID *pguidObjType,
  70. GUID *pguidInhObjType,
  71. DWORD dwAccessMask,
  72. LPCTSTR pszComputerName ) : m_Sid( pSid, pszComputerName ),
  73. m_bACEType( bACEType ),
  74. m_bACEFlags( bACEFlags ),
  75. m_pguidObjType(NULL),
  76. m_pguidInhObjType(NULL),
  77. m_dwAccessMask( dwAccessMask )
  78. {
  79. if(pguidObjType != NULL)
  80. {
  81. SetObjType(*pguidObjType);
  82. }
  83. if(pguidInhObjType != NULL)
  84. {
  85. SetInhObjType(*pguidInhObjType);
  86. }
  87. }
  88. ///////////////////////////////////////////////////////////////////
  89. //
  90. // Function: CAccessEntry::CAccessEntry
  91. //
  92. // Class constructor.
  93. //
  94. // Inputs:
  95. // PSID pSid - Sid to intialize from
  96. // BYTE bACEType - ACE Type
  97. // BYTE bACEFlags - Flags.
  98. // DWORD dwAccessMask - Access Mask
  99. // char* pszComputerName - Computer name to
  100. // init SID from.
  101. //
  102. // Outputs:
  103. // None.
  104. //
  105. // Returns:
  106. // None.
  107. //
  108. // Comments:
  109. //
  110. ///////////////////////////////////////////////////////////////////
  111. CAccessEntry::CAccessEntry( PSID pSid,
  112. BYTE bACEType,
  113. BYTE bACEFlags,
  114. GUID *pguidObjType,
  115. GUID *pguidInhObjType,
  116. DWORD dwAccessMask,
  117. LPCTSTR pszComputerName,
  118. bool fLookup ) : m_Sid( pSid, pszComputerName, fLookup ),
  119. m_bACEType( bACEType ),
  120. m_bACEFlags( bACEFlags ),
  121. m_pguidObjType(NULL),
  122. m_pguidInhObjType(NULL),
  123. m_dwAccessMask( dwAccessMask )
  124. {
  125. if(pguidObjType != NULL)
  126. {
  127. SetObjType(*pguidObjType);
  128. }
  129. if(pguidInhObjType != NULL)
  130. {
  131. SetInhObjType(*pguidInhObjType);
  132. }
  133. }
  134. ///////////////////////////////////////////////////////////////////
  135. //
  136. // Function: CAccessEntry::CAccessEntry
  137. //
  138. // Class constructor.
  139. //
  140. // Inputs:
  141. // CSid& sid - Sid to intialize from
  142. // BYTE bACEType - ACE Type
  143. // BYTE bACEFlags - Flags.
  144. // DWORD dwAccessMask - Access Mask
  145. // char* pszComputerName - Computer name to
  146. // init SID from.
  147. //
  148. // Outputs:
  149. // None.
  150. //
  151. // Returns:
  152. // None.
  153. //
  154. // Comments:
  155. //
  156. ///////////////////////////////////////////////////////////////////
  157. CAccessEntry::CAccessEntry( const CSid& sid,
  158. BYTE bACEType,
  159. BYTE bACEFlags,
  160. GUID *pguidObjType,
  161. GUID *pguidInhObjType,
  162. DWORD dwAccessMask,
  163. LPCTSTR pszComputerName ) : m_Sid( sid ),
  164. m_bACEType( bACEType ),
  165. m_bACEFlags( bACEFlags ),
  166. m_pguidObjType(NULL),
  167. m_pguidInhObjType(NULL),
  168. m_dwAccessMask( dwAccessMask )
  169. {
  170. if(pguidObjType != NULL)
  171. {
  172. SetObjType(*pguidObjType);
  173. }
  174. if(pguidInhObjType != NULL)
  175. {
  176. SetInhObjType(*pguidInhObjType);
  177. }
  178. }
  179. ///////////////////////////////////////////////////////////////////
  180. //
  181. // Function: CAccessEntry::CAccessEntry
  182. //
  183. // Class constructor.
  184. //
  185. // Inputs:
  186. // char* pszAccountName - Account Name
  187. // BYTE bACEType - ACE Type
  188. // BYTE bACEFlags - Flags.
  189. // DWORD dwAccessMask - Access Mask
  190. // char* pszComputerName - Computer name to
  191. // init SID from.
  192. //
  193. // Outputs:
  194. // None.
  195. //
  196. // Returns:
  197. // None.
  198. //
  199. // Comments:
  200. //
  201. ///////////////////////////////////////////////////////////////////
  202. CAccessEntry::CAccessEntry( LPCTSTR pszAccountName,
  203. BYTE bACEType,
  204. BYTE bACEFlags,
  205. GUID *pguidObjType,
  206. GUID *pguidInhObjType,
  207. DWORD dwAccessMask,
  208. LPCTSTR pszComputerName ) : m_Sid( pszAccountName, pszComputerName ),
  209. m_bACEType( bACEType ),
  210. m_pguidObjType(NULL),
  211. m_pguidInhObjType(NULL),
  212. m_bACEFlags( bACEFlags ),
  213. m_dwAccessMask( dwAccessMask )
  214. {
  215. if(pguidObjType != NULL)
  216. {
  217. SetObjType(*pguidObjType);
  218. }
  219. if(pguidInhObjType != NULL)
  220. {
  221. SetInhObjType(*pguidInhObjType);
  222. }
  223. }
  224. ///////////////////////////////////////////////////////////////////
  225. //
  226. // Function: CAccessEntry::CAccessEntry
  227. //
  228. // Class copy constructor.
  229. //
  230. // Inputs:
  231. // const CAccessEntry r_AccessEntry - object to copy.
  232. //
  233. // Outputs:
  234. // None.
  235. //
  236. // Returns:
  237. // None.
  238. //
  239. // Comments:
  240. //
  241. ///////////////////////////////////////////////////////////////////
  242. CAccessEntry::CAccessEntry( const CAccessEntry &r_AccessEntry )
  243. :
  244. m_Sid(),
  245. m_bACEType( 0 ),
  246. m_bACEFlags( 0 ),
  247. m_dwAccessMask( 0 ),
  248. m_pguidObjType(NULL),
  249. m_pguidInhObjType(NULL)
  250. {
  251. // Copy the values over
  252. m_Sid = r_AccessEntry.m_Sid;
  253. m_dwAccessMask = r_AccessEntry.m_dwAccessMask;
  254. m_bACEType = r_AccessEntry.m_bACEType;
  255. m_bACEFlags = r_AccessEntry.m_bACEFlags;
  256. if(r_AccessEntry.m_pguidObjType != NULL)
  257. {
  258. SetObjType(*(r_AccessEntry.m_pguidObjType));
  259. }
  260. if(r_AccessEntry.m_pguidInhObjType != NULL)
  261. {
  262. SetInhObjType(*(r_AccessEntry.m_pguidInhObjType));
  263. }
  264. }
  265. ///////////////////////////////////////////////////////////////////
  266. //
  267. // Function: CAccessEntry::CAccessEntry
  268. //
  269. // Assignment operator.
  270. //
  271. // Inputs:
  272. // const CAccessEntry r_AccessEntry - object to copy.
  273. //
  274. // Outputs:
  275. // None.
  276. //
  277. // Returns:
  278. // None.
  279. //
  280. // Comments:
  281. //
  282. ///////////////////////////////////////////////////////////////////
  283. CAccessEntry & CAccessEntry::operator= ( const CAccessEntry &r_AccessEntry )
  284. {
  285. // Copy the values over
  286. m_Sid = r_AccessEntry.m_Sid;
  287. m_dwAccessMask = r_AccessEntry.m_dwAccessMask;
  288. m_bACEType = r_AccessEntry.m_bACEType;
  289. m_bACEFlags = r_AccessEntry.m_bACEFlags;
  290. if(r_AccessEntry.m_pguidObjType != NULL)
  291. {
  292. SetObjType(*(r_AccessEntry.m_pguidObjType));
  293. }
  294. if(r_AccessEntry.m_pguidInhObjType != NULL)
  295. {
  296. SetInhObjType(*(r_AccessEntry.m_pguidInhObjType));
  297. }
  298. return (*this);
  299. }
  300. ///////////////////////////////////////////////////////////////////
  301. //
  302. // Function: CAccessEntry::CAccessEntry
  303. //
  304. // == Comparison operator.
  305. //
  306. // Inputs:
  307. // const CAccessEntry r_AccessEntry - object to compare.
  308. //
  309. // Outputs:
  310. // None.
  311. //
  312. // Returns:
  313. // None.
  314. //
  315. // Comments:
  316. //
  317. ///////////////////////////////////////////////////////////////////
  318. bool CAccessEntry::operator== ( const CAccessEntry &r_AccessEntry )
  319. {
  320. bool fRet = false;
  321. if( m_Sid == r_AccessEntry.m_Sid
  322. && m_dwAccessMask == r_AccessEntry.m_dwAccessMask
  323. && m_bACEType == r_AccessEntry.m_bACEType
  324. && m_bACEFlags == r_AccessEntry.m_bACEFlags)
  325. {
  326. if((r_AccessEntry.m_pguidObjType == NULL && m_pguidObjType == NULL) ||
  327. ((r_AccessEntry.m_pguidObjType != NULL && m_pguidObjType != NULL) &&
  328. (*(r_AccessEntry.m_pguidObjType) == *m_pguidObjType)))
  329. {
  330. if((r_AccessEntry.m_pguidInhObjType == NULL && m_pguidInhObjType == NULL) ||
  331. ((r_AccessEntry.m_pguidInhObjType != NULL && m_pguidInhObjType != NULL) &&
  332. (*(r_AccessEntry.m_pguidInhObjType) == *m_pguidInhObjType)))
  333. {
  334. fRet = true;
  335. }
  336. }
  337. }
  338. return fRet;
  339. }
  340. ///////////////////////////////////////////////////////////////////
  341. //
  342. // Function: CAccessEntry::~CAccessEntry
  343. //
  344. // Class Destructor
  345. //
  346. // Inputs:
  347. // None.
  348. //
  349. // Outputs:
  350. // None.
  351. //
  352. // Returns:
  353. // None.
  354. //
  355. // Comments:
  356. //
  357. ///////////////////////////////////////////////////////////////////
  358. CAccessEntry::~CAccessEntry( void )
  359. {
  360. if(m_pguidObjType != NULL) delete m_pguidObjType;
  361. if(m_pguidInhObjType != NULL) delete m_pguidInhObjType;
  362. }
  363. ///////////////////////////////////////////////////////////////////
  364. //
  365. // Function: CAccessEntry::AllocateACE
  366. //
  367. // Helper function to allocate an appropriate ACE object so outside
  368. // code can quickly and easily fill out PACLs.
  369. //
  370. // Inputs:
  371. // None.
  372. //
  373. // Outputs:
  374. // ACE_HEADER** ppACEHeader - Pointer to allocated
  375. // ACE Header.
  376. //
  377. // Returns:
  378. // BOOL Succes/Failure
  379. //
  380. // Comments:
  381. //
  382. // User should use FreeACE to free the allocated object.
  383. //
  384. ///////////////////////////////////////////////////////////////////
  385. BOOL CAccessEntry::AllocateACE( ACE_HEADER** ppACEHeader )
  386. {
  387. // Clear out the structure
  388. *ppACEHeader = NULL;
  389. if ( m_Sid.IsValid() )
  390. {
  391. ACE_HEADER* pACEHeader = NULL;
  392. WORD wAceSize = 0;
  393. DWORD dwSidLength = m_Sid.GetLength();
  394. switch ( m_bACEType )
  395. {
  396. case ACCESS_ALLOWED_ACE_TYPE:
  397. {
  398. wAceSize = sizeof( ACCESS_ALLOWED_ACE ) + dwSidLength - sizeof(DWORD);
  399. // Allocate the appropriate Ace and fill out its values.
  400. ACCESS_ALLOWED_ACE* pACE = NULL;
  401. try
  402. {
  403. pACE = (ACCESS_ALLOWED_ACE*) malloc( wAceSize );
  404. if ( NULL != pACE )
  405. {
  406. pACE->Mask = m_dwAccessMask;
  407. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  408. pACEHeader = (ACE_HEADER*) pACE;
  409. }
  410. }
  411. catch(...)
  412. {
  413. if(pACE != NULL)
  414. {
  415. free(pACE);
  416. pACE = NULL;
  417. }
  418. throw;
  419. }
  420. }
  421. break;
  422. case ACCESS_DENIED_ACE_TYPE:
  423. {
  424. wAceSize = sizeof( ACCESS_DENIED_ACE ) + dwSidLength - sizeof(DWORD);
  425. // Allocate the appropriate Ace and fill out its values.
  426. ACCESS_DENIED_ACE* pACE = NULL;
  427. try
  428. {
  429. pACE = (ACCESS_DENIED_ACE*) malloc( wAceSize );
  430. if ( NULL != pACE )
  431. {
  432. pACE->Mask = m_dwAccessMask;
  433. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  434. pACEHeader = (ACE_HEADER*) pACE;
  435. }
  436. }
  437. catch(...)
  438. {
  439. if(pACE != NULL)
  440. {
  441. free(pACE);
  442. pACE = NULL;
  443. }
  444. throw;
  445. }
  446. }
  447. break;
  448. case SYSTEM_AUDIT_ACE_TYPE:
  449. {
  450. wAceSize = sizeof( SYSTEM_AUDIT_ACE ) + dwSidLength - sizeof(DWORD);
  451. // Allocate the appropriate Ace and fill out its values.
  452. SYSTEM_AUDIT_ACE* pACE = NULL;
  453. try
  454. {
  455. pACE = (SYSTEM_AUDIT_ACE*) malloc( wAceSize );
  456. if ( NULL != pACE )
  457. {
  458. pACE->Mask = m_dwAccessMask;
  459. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  460. pACEHeader = (ACE_HEADER*) pACE;
  461. }
  462. }
  463. catch(...)
  464. {
  465. if(pACE != NULL)
  466. {
  467. free(pACE);
  468. pACE = NULL;
  469. }
  470. throw;
  471. }
  472. }
  473. break;
  474. case ACCESS_ALLOWED_OBJECT_ACE_TYPE:
  475. {
  476. wAceSize = sizeof( ACCESS_ALLOWED_OBJECT_ACE ) + dwSidLength - sizeof(DWORD);
  477. // Allocate the appropriate Ace and fill out its values.
  478. ACCESS_ALLOWED_OBJECT_ACE* pACE = NULL;
  479. try
  480. {
  481. pACE = (ACCESS_ALLOWED_OBJECT_ACE*) malloc( wAceSize );
  482. if ( NULL != pACE )
  483. {
  484. pACE->Mask = m_dwAccessMask;
  485. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  486. pACEHeader = (ACE_HEADER*) pACE;
  487. if(m_pguidObjType != NULL)
  488. {
  489. memcpy(&(pACE->ObjectType), m_pguidObjType, sizeof(GUID));
  490. pACE->Flags |= ACE_OBJECT_TYPE_PRESENT;
  491. }
  492. if(m_pguidInhObjType != NULL)
  493. {
  494. memcpy(&(pACE->InheritedObjectType), m_pguidInhObjType, sizeof(GUID));
  495. pACE->Flags |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
  496. }
  497. }
  498. }
  499. catch(...)
  500. {
  501. if(pACE != NULL)
  502. {
  503. free(pACE);
  504. pACE = NULL;
  505. }
  506. throw;
  507. }
  508. }
  509. break;
  510. /************************* this type has not been implemented yet on W2K *************************************
  511. case ACCESS_ALLOWED_COMPOUND_ACE_TYPE:
  512. {
  513. wAceSize = sizeof( ACCESS_ALLOWED_COMPOUND_ACE ) + dwSidLength - sizeof(DWORD);
  514. // Allocate the appropriate Ace and fill out its values.
  515. ACCESS_ALLOWED_COMPOUND_ACE* pACE = NULL;
  516. try
  517. {
  518. pACE = (ACCESS_ALLOWED_COMPOUND_ACE*) malloc( wAceSize );
  519. if ( NULL != pACE )
  520. {
  521. pACE->Mask = m_dwAccessMask;
  522. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  523. pACEHeader = (ACE_HEADER*) pACE;
  524. memcpy(&(pACE->ObjectType), m_pguidObjType, sizeof(GUID));
  525. memcpy(&(pACE->InheritedObjectType), m_pguidInhObjType, sizeof(GUID));
  526. }
  527. }
  528. catch(...)
  529. {
  530. if(pACE != NULL)
  531. {
  532. free(pACE);
  533. pACE = NULL;
  534. }
  535. throw;
  536. }
  537. }
  538. break;
  539. *************************************************************************************************************/
  540. case ACCESS_DENIED_OBJECT_ACE_TYPE:
  541. {
  542. wAceSize = sizeof( ACCESS_DENIED_OBJECT_ACE ) + dwSidLength - sizeof(DWORD);
  543. // Allocate the appropriate Ace and fill out its values.
  544. ACCESS_DENIED_OBJECT_ACE* pACE = NULL;
  545. try
  546. {
  547. pACE = (ACCESS_DENIED_OBJECT_ACE*) malloc( wAceSize );
  548. if ( NULL != pACE )
  549. {
  550. pACE->Mask = m_dwAccessMask;
  551. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  552. pACEHeader = (ACE_HEADER*) pACE;
  553. if(m_pguidObjType != NULL)
  554. {
  555. memcpy(&(pACE->ObjectType), m_pguidObjType, sizeof(GUID));
  556. pACE->Flags |= ACE_OBJECT_TYPE_PRESENT;
  557. }
  558. if(m_pguidInhObjType != NULL)
  559. {
  560. memcpy(&(pACE->InheritedObjectType), m_pguidInhObjType, sizeof(GUID));
  561. pACE->Flags |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
  562. }
  563. }
  564. }
  565. catch(...)
  566. {
  567. if(pACE != NULL)
  568. {
  569. free(pACE);
  570. pACE = NULL;
  571. }
  572. throw;
  573. }
  574. }
  575. break;
  576. case SYSTEM_AUDIT_OBJECT_ACE_TYPE:
  577. {
  578. wAceSize = sizeof( SYSTEM_AUDIT_OBJECT_ACE ) + dwSidLength - sizeof(DWORD);
  579. // Allocate the appropriate Ace and fill out its values.
  580. SYSTEM_AUDIT_OBJECT_ACE* pACE = NULL;
  581. try
  582. {
  583. pACE = (SYSTEM_AUDIT_OBJECT_ACE*) malloc( wAceSize );
  584. if ( NULL != pACE )
  585. {
  586. pACE->Mask = m_dwAccessMask;
  587. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  588. pACEHeader = (ACE_HEADER*) pACE;
  589. if(m_pguidObjType != NULL)
  590. {
  591. memcpy(&(pACE->ObjectType), m_pguidObjType, sizeof(GUID));
  592. pACE->Flags |= ACE_OBJECT_TYPE_PRESENT;
  593. }
  594. if(m_pguidInhObjType != NULL)
  595. {
  596. memcpy(&(pACE->InheritedObjectType), m_pguidInhObjType, sizeof(GUID));
  597. pACE->Flags |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
  598. }
  599. }
  600. }
  601. catch(...)
  602. {
  603. if(pACE != NULL)
  604. {
  605. free(pACE);
  606. pACE = NULL;
  607. }
  608. throw;
  609. }
  610. }
  611. break;
  612. /********************************* type not yet supported under w2k ********************************************
  613. case SYSTEM_ALARM_ACE_TYPE:
  614. {
  615. wAceSize = sizeof( SYSTEM_ALARM_ACE ) + dwSidLength - sizeof(DWORD);
  616. // Allocate the appropriate Ace and fill out its values.
  617. SYSTEM_ALARM_ACE* pACE = NULL;
  618. try
  619. {
  620. pACE = (SYSTEM_ALARM_ACE*) malloc( wAceSize );
  621. if ( NULL != pACE )
  622. {
  623. pACE->Mask = m_dwAccessMask;
  624. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  625. pACEHeader = (ACE_HEADER*) pACE;
  626. }
  627. }
  628. catch(...)
  629. {
  630. if(pACE != NULL)
  631. {
  632. free(pACE);
  633. pACE = NULL;
  634. }
  635. throw;
  636. }
  637. }
  638. break;
  639. /********************************* type not yet supported under w2k ********************************************/
  640. /********************************* type not yet supported under w2k ********************************************
  641. case SYSTEM_ALARM_OBJECT_ACE_TYPE:
  642. {
  643. wAceSize = sizeof( SYSTEM_ALARM_OBJECT_ACE ) + dwSidLength - sizeof(DWORD);
  644. // Allocate the appropriate Ace and fill out its values.
  645. SYSTEM_ALARM_OBJECT_ACE* pACE = NULL;
  646. try
  647. {
  648. pACE = (SYSTEM_ALARM_OBJECT_ACE*) malloc( wAceSize );
  649. if ( NULL != pACE )
  650. {
  651. pACE->Mask = m_dwAccessMask;
  652. CopySid( dwSidLength, (PSID) &pACE->SidStart, m_Sid.GetPSid() );
  653. pACEHeader = (ACE_HEADER*) pACE;
  654. if(m_pguidObjType != NULL)
  655. {
  656. memcpy(&(pACE->ObjectType), m_pguidObjType, sizeof(GUID));
  657. pACE->Flags |= ACE_OBJECT_TYPE_PRESENT;
  658. }
  659. if(m_pguidInhObjType != NULL)
  660. {
  661. memcpy(&(pACE->InheritedObjectType), m_pguidInhObjType, sizeof(GUID));
  662. pACE->Flags |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
  663. }
  664. }
  665. }
  666. catch(...)
  667. {
  668. if(pACE != NULL)
  669. {
  670. free(pACE);
  671. pACE = NULL;
  672. }
  673. throw;
  674. }
  675. }
  676. break;
  677. /********************************* type not yet supported under w2k ********************************************/
  678. default:
  679. {
  680. // Something bad just happened
  681. ASSERT_BREAK(0);
  682. }
  683. } // SWITCH
  684. // Fill out the common values, then store the value for return.
  685. if ( NULL != pACEHeader )
  686. {
  687. pACEHeader->AceType = m_bACEType;
  688. pACEHeader->AceFlags = m_bACEFlags;
  689. pACEHeader->AceSize = wAceSize;
  690. *ppACEHeader = pACEHeader;
  691. }
  692. }
  693. // Return whether or not a valid ACE is coming out
  694. return ( NULL != *ppACEHeader );
  695. }
  696. void CAccessEntry::DumpAccessEntry(LPCWSTR wstrFilename)
  697. {
  698. CHString chstrTemp1;
  699. Output(L"ACE contents follow...", wstrFilename);
  700. // Dump the access mask...
  701. chstrTemp1.Format(L"ACE access mask (hex): %x", m_dwAccessMask);
  702. Output(chstrTemp1, wstrFilename);
  703. // Dump the ace type...
  704. chstrTemp1.Format(L"ACE type (hex): %x", m_bACEType);
  705. Output(chstrTemp1, wstrFilename);
  706. // Dump the ace flags...
  707. chstrTemp1.Format(L"ACE flags (hex): %x", m_bACEFlags);
  708. Output(chstrTemp1, wstrFilename);
  709. // Dump the ace sid...
  710. m_Sid.DumpSid(wstrFilename);
  711. }