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.

934 lines
27 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. * This module contains the wrappers for SAM objects.
  7. *
  8. * Two Hierarchies are presented in this file.
  9. *
  10. * The first is the SAM_MEMORY hierarchy. These are a set of classes
  11. * used to wrap the various structures returned by SAM Apis. This
  12. * allows easy access to the members of each of the array of structures
  13. * which SAM returns. Also, it gives automatic freeing of the memory
  14. * allocated by SAM when the MEM object is destructed. Clients will
  15. * generally create the appropriate MEM object, and pass a pointer to
  16. * it into the appropriate method of the desired SAM_OBJECT class.
  17. *
  18. * BASE
  19. * |
  20. * NT_MEMORY
  21. * |
  22. * SAM_MEMORY
  23. * |
  24. * +---------+--------+--------------------+
  25. * | | | |
  26. * SAM_RID_MEM | SAM_SID_MEM SAM_RID_ENUMERATION_MEM
  27. * |
  28. * SAM_PASSWORD_MEM
  29. *
  30. *
  31. * Second, the SAM_OBJECT hierarchy is a thin wrapper around the
  32. * SAM apis. These classes store the appropriate SAM handle, and
  33. * provide access to the SAM apis which operate on that handle.
  34. *
  35. * BASE
  36. * |
  37. * SAM_OBJECT
  38. * |
  39. * +------------------------------------------------------+
  40. * | | | | |
  41. * SAM_SERVER SAM_DOMAIN SAM_ALIAS SAM_USER SAM_GROUP
  42. *
  43. * One more class is presented in this file, ADMIN_AUTHORITY. This
  44. * class creates and contains a SAM_SERVER, two SAM_DOMAINS corresponding
  45. * to the BuiltIn domain and Account domain on the server, and an LSA_OBJECT.
  46. * Thus, the User Manager (for example) can create a single object to
  47. * access all SAM and LSA functions.
  48. *
  49. *
  50. *
  51. * History
  52. * jonn 01/17/92 Created
  53. * thomaspa 02/22/92 Split int hxx/cxx
  54. * thomaspa 03/03/92 Split out ntlsa.hxx
  55. * jonn 07/07/92 Added SAM_USER
  56. */
  57. #ifndef _UINTSAM_HXX_
  58. #define _UINTSAM_HXX_
  59. #include "uiassert.hxx"
  60. #include "uintmem.hxx"
  61. #include "uintlsa.hxx"
  62. #include "security.hxx"
  63. #include "apisess.hxx"
  64. // Forward declaration
  65. DLL_CLASS ALIAS_ENUM;
  66. #define DEF_SAM_SERVER_ACCESS SAM_SERVER_LOOKUP_DOMAIN
  67. #define DEF_SAM_DOMAIN_ACCESS GENERIC_EXECUTE
  68. #define DEF_SAM_ALIAS_ACCESS ALIAS_ALL_ACCESS
  69. #define DEF_SAM_USER_ACCESS USER_ALL_ACCESS
  70. #define DEF_SAM_GROUP_ACCESS GROUP_ALL_ACCESS
  71. #define DEF_REQ_ENUM_BUFFSIZE 0x10000
  72. /**********************************************************\
  73. NAME: SAM_MEMORY
  74. SYNOPSIS: Specialized buffer object for storing data returned
  75. from SAM APIs.
  76. INTERFACE: SAM_MEMORY(): constructor
  77. ~SAM_MEMORY(): destructor
  78. NOTES: This is a base class for specialized wrapper classes
  79. which wrap structures returned by SAM APIs. This class
  80. provides a framework for accessing and freeing these
  81. buffers.
  82. PARENT: NT_MEMORY
  83. HISTORY:
  84. thomaspa 03/03/92 Created
  85. \**********************************************************/
  86. DLL_CLASS SAM_MEMORY : public NT_MEMORY
  87. {
  88. private:
  89. BOOL _fOwnerAlloc;
  90. protected:
  91. SAM_MEMORY( BOOL fOwnerAlloc = FALSE );
  92. /*
  93. * Frees an SAM allocated buffer
  94. */
  95. inline virtual void FreeBuffer()
  96. {
  97. if ( QueryBuffer() != NULL )
  98. {
  99. REQUIRE( ::SamFreeMemory( QueryBuffer() ) == STATUS_SUCCESS );
  100. }
  101. }
  102. public:
  103. ~SAM_MEMORY();
  104. /*
  105. * Frees the existing buffer and sets a new buffer and count of items
  106. */
  107. inline virtual void Set( VOID * pvBuffer, ULONG cItems )
  108. {
  109. if ( !_fOwnerAlloc )
  110. FreeBuffer();
  111. NT_MEMORY::Set( pvBuffer, cItems );
  112. }
  113. };
  114. /**********************************************************\
  115. NAME: SAM_RID_MEM (samrm)
  116. SYNOPSIS: Wrapper buffer for arrays of RIDs.
  117. INTERFACE: SAM_RID_MEM(): constructor
  118. ~SAM_RID_MEM(): destructor
  119. QueryRID(): Query Rid
  120. PARENT: SAM_MEMORY
  121. HISTORY:
  122. jonn 01/17/92 Created
  123. \**********************************************************/
  124. DLL_CLASS SAM_RID_MEM : public SAM_MEMORY
  125. {
  126. private:
  127. /*
  128. * Return a properly casted pointer to the buffer
  129. */
  130. inline const ULONG * QueryPtr() const
  131. {
  132. return (ULONG *)QueryBuffer();
  133. }
  134. public:
  135. SAM_RID_MEM( BOOL fOwnerAlloc = FALSE );
  136. ~SAM_RID_MEM();
  137. /*
  138. * return the RID for the ith entry in the buffer
  139. */
  140. inline ULONG QueryRID( ULONG i ) const
  141. {
  142. ASSERT( IsInRange( i ) );
  143. return QueryPtr()[i];
  144. }
  145. };
  146. /**********************************************************\
  147. NAME: SAM_SID_MEM (samsm)
  148. SYNOPSIS: Wrapper buffer for arrays of PSIDs.
  149. INTERFACE: SAM_SID_MEM(): constructor
  150. ~SAM_SID_MEM(): destructor
  151. QueryPSID(): Query PSID
  152. PARENT: SAM_MEMORY
  153. HISTORY:
  154. jonn 01/17/92 Created
  155. \**********************************************************/
  156. DLL_CLASS SAM_SID_MEM : public SAM_MEMORY
  157. {
  158. public:
  159. SAM_SID_MEM( BOOL fOwnerAlloc = FALSE );
  160. ~SAM_SID_MEM();
  161. /*
  162. * Return the PSID for the ith entry in the buffer
  163. */
  164. inline PSID QueryPSID( ULONG i ) const
  165. {
  166. ASSERT( IsInRange( i ) );
  167. return QueryPtr()[i];
  168. }
  169. /*
  170. * Return a properly casted pointer to the buffer
  171. */
  172. inline PSID * QueryPtr() const
  173. {
  174. return (PSID *)QueryBuffer();
  175. }
  176. };
  177. /**********************************************************\
  178. NAME: SAM_RID_ENUMERATION_MEM (samrem)
  179. SYNOPSIS: Specialized buffer object for storing data returned
  180. from SAM APIs, specifically SAM_RID_ENUMERATION structs.
  181. INTERFACE: SAM_RID_ENUMERATION_MEM(): constructor
  182. ~SAM_RID_ENUMERATION_MEM(): destructor
  183. QueryRID(): query a RID from the buffer
  184. QueryName(): Query a name from the buffer
  185. PARENT: SAM_MEMORY
  186. HISTORY:
  187. thomaspa 02/20/92 Created
  188. \**********************************************************/
  189. DLL_CLASS SAM_RID_ENUMERATION_MEM : public SAM_MEMORY
  190. {
  191. public:
  192. SAM_RID_ENUMERATION_MEM( BOOL fOwnerAlloc = FALSE );
  193. ~SAM_RID_ENUMERATION_MEM();
  194. /*
  195. * Return a properly casted pointer to the buffer
  196. */
  197. inline const SAM_RID_ENUMERATION * QueryPtr() const
  198. {
  199. return (SAM_RID_ENUMERATION *)QueryBuffer();
  200. }
  201. /*
  202. * return the UNICODE_STRING name for the ith entry in the buffer
  203. */
  204. inline const UNICODE_STRING * QueryUnicodeName( ULONG i ) const
  205. {
  206. ASSERT( IsInRange( i ) );
  207. return &(QueryPtr()[i].Name);
  208. }
  209. /*
  210. * Return the RID for the ith entry in the buffer
  211. */
  212. inline ULONG QueryRID( ULONG i ) const
  213. {
  214. ASSERT( IsInRange( i ) );
  215. return QueryPtr()[i].RelativeId;
  216. }
  217. /*
  218. * Return the NLS_STR name for the ith entry in the buffer
  219. */
  220. inline APIERR QueryName( ULONG i, NLS_STR * pnlsName ) const
  221. {
  222. ASSERT( pnlsName != NULL );
  223. return pnlsName->MapCopyFrom( QueryUnicodeName( i )->Buffer,
  224. QueryUnicodeName( i )->Length );
  225. }
  226. } ;
  227. /**********************************************************\
  228. NAME: SAM_SID_NAME_USE_MEM (samsnum)
  229. SYNOPSIS: Specialized buffer object for storing data returned
  230. from SAM APIs, specifically SID_NAME_USE structs.
  231. INTERFACE: SAM_SID_NAME_USE_MEM(): constructor
  232. ~SAM_SID_NAME_USE_MEM(): destructor
  233. QueryUse(): query a Name Use from the buffer
  234. PARENT: SAM_MEMORY
  235. HISTORY:
  236. thomaspa 02/20/92 Created
  237. \**********************************************************/
  238. DLL_CLASS SAM_SID_NAME_USE_MEM : public SAM_MEMORY
  239. {
  240. private:
  241. /*
  242. * Return a properly casted pointer to the buffer
  243. */
  244. inline const SID_NAME_USE * QueryPtr() const
  245. {
  246. return (SID_NAME_USE *)QueryBuffer();
  247. }
  248. public:
  249. SAM_SID_NAME_USE_MEM( BOOL fOwnerAlloc = FALSE );
  250. ~SAM_SID_NAME_USE_MEM();
  251. /*
  252. * return the SID_NAME_USE for the ith entry in the buffer
  253. */
  254. inline SID_NAME_USE QueryUse( ULONG i ) const
  255. {
  256. ASSERT( IsInRange( i ) );
  257. return QueryPtr()[i];
  258. }
  259. } ;
  260. /**********************************************************\
  261. NAME: SAM_PSWD_DOM_INFO_MEM (sampswdinfo)
  262. SYNOPSIS: Wrapper for DOMAIN_PASSWORD_INFORMATION
  263. INTERFACE: SAM_PSWD_DOM_INFO_MEM(): constructor
  264. ~SAM_PSWD_DOM_INFO_MEM(): destructor
  265. QueryNoAnonChange(): Query whether anonymous password change
  266. allowed
  267. SetNoAnonChange()
  268. PARENT: SAM_MEMORY
  269. NOTES: Accessors not created for other fields, create if needed
  270. HISTORY:
  271. JonN 12/23/93 Created
  272. \**********************************************************/
  273. DLL_CLASS SAM_PSWD_DOM_INFO_MEM : public SAM_MEMORY
  274. {
  275. private:
  276. DOMAIN_PASSWORD_INFORMATION * QueryUpdatePtr () const
  277. {
  278. return (DOMAIN_PASSWORD_INFORMATION *) QueryBuffer() ;
  279. }
  280. public:
  281. /*
  282. * Returns a properly casted pointer the the buffer
  283. */
  284. const DOMAIN_PASSWORD_INFORMATION * QueryPtr () const
  285. {
  286. return (DOMAIN_PASSWORD_INFORMATION *) QueryBuffer();
  287. }
  288. SAM_PSWD_DOM_INFO_MEM( BOOL fOwnerAlloc = FALSE );
  289. ~SAM_PSWD_DOM_INFO_MEM();
  290. BOOL QueryNoAnonChange();
  291. void SetNoAnonChange( BOOL fNoAnonChange );
  292. };
  293. /**********************************************************\
  294. NAME: SAM_OBJECT
  295. SYNOPSIS: Wrapper for SAM-handle-based C++ objects. This class
  296. is a pure virtual parent class for SAM_SERVER,
  297. SAM_DOMAIN and SAM_ALIAS. Its only function at present
  298. is to remember the SAM_HANDLE and to free it when done.
  299. INTERFACE: (protected)
  300. SAM_OBJECT(): constructor
  301. SetHandle(): Store handle to object. SetHandle()
  302. should be called at most once, by the subclass
  303. constructor.
  304. QueryHandle(): Query handle to object
  305. PARENT: BASE
  306. HISTORY:
  307. jonn 01/17/92 Created
  308. thomaspa 04/17/92 Improved handle handling
  309. \**********************************************************/
  310. DLL_CLASS SAM_OBJECT : public BASE
  311. {
  312. private:
  313. SAM_HANDLE _hsam;
  314. BOOL _fHandleValid ;
  315. protected:
  316. SAM_OBJECT();
  317. ~SAM_OBJECT();
  318. /*
  319. * Sets the handle for a SAM_OBJECT. Should only be
  320. * called once for any object
  321. */
  322. inline void SetHandle( SAM_HANDLE hsam )
  323. {
  324. ASSERT( !_fHandleValid );
  325. ASSERT( hsam != NULL );
  326. _hsam = hsam;
  327. _fHandleValid = TRUE ;
  328. }
  329. inline void ResetHandle ( )
  330. {
  331. _fHandleValid = FALSE ;
  332. _hsam = NULL ;
  333. }
  334. public:
  335. // Returns TRUE if handle is present and valid
  336. inline BOOL IsHandleValid () const
  337. { return _fHandleValid ; }
  338. // Returns the SAM_HANDLE for this object
  339. inline SAM_HANDLE QueryHandle() const
  340. {
  341. return _fHandleValid ? _hsam : NULL ;
  342. }
  343. // Close the handle and invalidate it.
  344. APIERR CloseHandle ( ) ;
  345. } ;
  346. /**********************************************************\
  347. NAME: SAM_SERVER (samsrv)
  348. SYNOPSIS: Wrapper for SAM server APIs. This class provides
  349. access to the SAM APIs relating to ServerHandles. At
  350. present, this only includes creating and deleting these
  351. handles.
  352. INTERFACE: (public)
  353. SAM_SERVER(): constructor
  354. ~SAM_SERVER(): destructor
  355. PARENT: SAM_OBJECT
  356. HISTORY:
  357. jonn 01/17/92 Created
  358. \**********************************************************/
  359. DLL_CLASS SAM_SERVER : public SAM_OBJECT
  360. {
  361. private:
  362. NLS_STR _nlsServerName;
  363. public:
  364. SAM_SERVER( const TCHAR * pszServerName,
  365. ACCESS_MASK accessDesired = DEF_SAM_SERVER_ACCESS );
  366. ~SAM_SERVER();
  367. const TCHAR * QueryServerName( void ) const
  368. { return (_nlsServerName.strlen() != 0)
  369. ? _nlsServerName.QueryPch()
  370. : NULL; }
  371. } ;
  372. /**********************************************************\
  373. NAME: SAM_DOMAIN (samdom)
  374. SYNOPSIS: Wrapper for SAM domain APIs. This class provides
  375. access to the SAM APIs relating to DomainHandles.
  376. Default access DOMAIN_ALL_ACCESS is required to enumerate
  377. aliases and create new aliases.
  378. INTERFACE: (public)
  379. SAM_DOMAIN(): constructor
  380. ~SAM_DOMAIN(): destructor
  381. EnumerateAliases():
  382. EnumerateUsers():
  383. EnumerateAliasesForUser():
  384. TranslateNamesToRids():
  385. RemoveMemberFromAliases():
  386. PARENT: SAM_OBJECT
  387. HISTORY:
  388. jonn 01/17/92 Created
  389. thomaspa 02/22/92 Many changes
  390. jonn 07/27/92 RemoveMemberFromAliases
  391. \**********************************************************/
  392. DLL_CLASS SAM_DOMAIN : public SAM_OBJECT
  393. {
  394. private:
  395. OS_SID _ossidDomain;
  396. APIERR OpenDomain( const SAM_SERVER & server,
  397. PSID psidDomain,
  398. ACCESS_MASK accessDesired );
  399. public:
  400. SAM_DOMAIN( const SAM_SERVER & server,
  401. PSID psidDomain,
  402. ACCESS_MASK accessDesired = DEF_SAM_DOMAIN_ACCESS );
  403. ~SAM_DOMAIN();
  404. // Get/Set the server role
  405. APIERR GetPasswordInfo ( SAM_PSWD_DOM_INFO_MEM * psampswdinfo ) const ;
  406. APIERR SetPasswordInfo ( const SAM_PSWD_DOM_INFO_MEM * psampswdinfo ) ;
  407. APIERR TranslateNamesToRids( const TCHAR * const * ppszNames,
  408. ULONG cNames,
  409. SAM_RID_MEM *psamrm,
  410. SAM_SID_NAME_USE_MEM *psamsnum) const;
  411. APIERR EnumerateAliases( SAM_RID_ENUMERATION_MEM * psamrem,
  412. PSAM_ENUMERATE_HANDLE psamenumh,
  413. ULONG cbRequested = DEF_REQ_ENUM_BUFFSIZE ) const;
  414. APIERR EnumerateGroups( SAM_RID_ENUMERATION_MEM * psamrem,
  415. PSAM_ENUMERATE_HANDLE psamenumh,
  416. ULONG cbRequested = DEF_REQ_ENUM_BUFFSIZE ) const;
  417. APIERR EnumerateUsers( SAM_RID_ENUMERATION_MEM * psamrem,
  418. PSAM_ENUMERATE_HANDLE psamenumh,
  419. ULONG fAccountControl,
  420. ULONG cbRequested = DEF_REQ_ENUM_BUFFSIZE ) const;
  421. APIERR EnumerateAliasesForUser( PSID psidUser,
  422. SAM_RID_MEM * psamrm ) const;
  423. APIERR RemoveMemberFromAliases( PSID psidMember );
  424. PSID QueryPSID( void ) const
  425. {
  426. return _ossidDomain.QuerySid();
  427. }
  428. const OS_SID * QueryOSSID( void ) const
  429. {
  430. return &_ossidDomain;
  431. }
  432. } ;
  433. /**********************************************************\
  434. NAME: SAM_ALIAS (samalias)
  435. SYNOPSIS: Wrapper for SAM alias APIs. This class provides
  436. access to the SAM APIs relating to AliasHandles.
  437. This includes creating and deleting these handles,
  438. querying alias membership, and modifying alias
  439. membership.
  440. INTERFACE: (public)
  441. SAM_ALIAS(): constructor
  442. ~SAM_ALIAS(): destructor
  443. Delete(): deletes alias. Do not use object after a
  444. successful call to Delete().
  445. GetMembers();
  446. AddMember():
  447. RemoveMember():
  448. GetComment():
  449. SetComment():
  450. QueryRid();
  451. PARENT: SAM_OBJECT
  452. HISTORY:
  453. jonn 01/17/92 Created
  454. \**********************************************************/
  455. DLL_CLASS SAM_ALIAS : public SAM_OBJECT
  456. {
  457. private:
  458. ULONG _ulRid;
  459. public:
  460. // Constructor for Opening an existing alias
  461. SAM_ALIAS( const SAM_DOMAIN & samdom,
  462. ULONG ulAliasRid,
  463. ACCESS_MASK accessDesired = DEF_SAM_ALIAS_ACCESS );
  464. // Constructor for Creating a new alias
  465. SAM_ALIAS( const SAM_DOMAIN & samdom,
  466. const TCHAR *pszName,
  467. ACCESS_MASK accessDesired = DEF_SAM_ALIAS_ACCESS );
  468. ~SAM_ALIAS();
  469. APIERR Delete();
  470. APIERR GetMembers( SAM_SID_MEM * psamsm );
  471. APIERR AddMember( PSID psidMemberID );
  472. APIERR RemoveMember( PSID psidMemberID );
  473. APIERR AddMembers( PSID * apsidMemberIDs, UINT cSidCount );
  474. APIERR RemoveMembers( PSID * apsidMemberIDs, UINT cSidCount );
  475. APIERR GetComment( NLS_STR * pnlsComment );
  476. APIERR SetComment( const NLS_STR * pnlsComment );
  477. ULONG QueryRID();
  478. } ;
  479. /**********************************************************\
  480. NAME: SAM_USER (samuser)
  481. SYNOPSIS: Wrapper for SAM user APIs. This class provides
  482. access to the SAM APIs relating to UserHandles.
  483. This includes creating and deleting these handles.
  484. This class does not provide all functionality
  485. relating to UserHandles, since the USER_x APIs
  486. are available for that purpose. It is intended
  487. to test creating UserHandles with specific access
  488. masks, to test what USER_x operations can be performed
  489. on a user without actually performing them. It also
  490. supports renaming a user.
  491. INTERFACE: (public)
  492. SAM_USER(): constructor
  493. ~SAM_USER(): destructor
  494. SetUsername(): rename user account
  495. PARENT: SAM_OBJECT
  496. HISTORY:
  497. jonn 07/07/92 Created
  498. \**********************************************************/
  499. DLL_CLASS SAM_USER : public SAM_OBJECT
  500. {
  501. private:
  502. ULONG _ulRid;
  503. public:
  504. // Constructor for Opening an existing user
  505. SAM_USER( const SAM_DOMAIN & samdom,
  506. ULONG ulUserRid,
  507. ACCESS_MASK accessDesired = DEF_SAM_USER_ACCESS );
  508. ~SAM_USER();
  509. APIERR SetUsername( const NLS_STR * pnlsUsername );
  510. // Perform SamChangePasswordUser()
  511. APIERR SetPassword ( const NLS_STR & nlsOldPassword,
  512. const NLS_STR & nlsNewPassword ) ;
  513. // Perform SamSetInformationUser() with just a password
  514. APIERR SetPassword ( const NLS_STR & nlsPassword,
  515. BOOL fPasswordExpired = FALSE ) ;
  516. ULONG QueryRID();
  517. } ;
  518. /**********************************************************\
  519. NAME: SAM_GROUP (samgroup)
  520. SYNOPSIS: Wrapper for SAM (global) group APIs. This class provides
  521. access to the SAM APIs relating to GroupHandles.
  522. This includes creating and deleting these handles.
  523. This class does not provide all functionality
  524. relating to GROUPHandles, since the GROUP_x APIs
  525. are available for that purpose. It is intended
  526. to test creating GroupHandles with specific access
  527. masks, to test what GROUP_x operations can be performed
  528. on a group without actually performing them.
  529. INTERFACE: (public)
  530. SAM_GROUP(): constructor
  531. ~SAM_GROUP(): destructor
  532. SetGroupname(): rename global group account
  533. PARENT: SAM_OBJECT
  534. HISTORY:
  535. jonn 07/07/92 Created
  536. \**********************************************************/
  537. DLL_CLASS SAM_GROUP : public SAM_OBJECT
  538. {
  539. private:
  540. ULONG _ulRid;
  541. public:
  542. // Constructor for Opening an existing group
  543. SAM_GROUP( const SAM_DOMAIN & samdom,
  544. ULONG ulGroupRid,
  545. ACCESS_MASK accessDesired = DEF_SAM_GROUP_ACCESS );
  546. ~SAM_GROUP();
  547. APIERR SetGroupname( const NLS_STR * pnlsGroupname );
  548. APIERR GetComment( NLS_STR * pnlsComment );
  549. APIERR GetMembers( SAM_RID_MEM * psamrm );
  550. APIERR AddMember( ULONG ridMemberID );
  551. APIERR RemoveMember( ULONG ridMemberID );
  552. APIERR AddMembers( ULONG * aridMemberIDs, UINT cRidCount );
  553. APIERR RemoveMembers( ULONG * aridMemberIDs, UINT cRidCount );
  554. ULONG QueryRID();
  555. } ;
  556. /**********************************************************\
  557. NAME: ADMIN_AUTHORITY (adminauth)
  558. SYNOPSIS:
  559. This class creates and contains a SAM_SERVER, two SAM_DOMAINS
  560. corresponding to the BuiltIn domain and Account domain on the
  561. server, and an LSA_OBJECT. Thus, the User Manager (for example)
  562. can create a single object to access all SAM and LSA functions.
  563. INTERFACE: (public)
  564. ADMIN_AUTHORITY(): constructor
  565. ~ADMIN_AUTHORITY(): destructor
  566. ReplaceSamServer():
  567. ReplaceLSAPolicy():
  568. ReplaceBuiltinDomain():
  569. ReplaceAccountDomain():
  570. Replace the current handle with one with the
  571. specified authority. If this fails, the old
  572. handle is intact and the ADMIN_AUTHORITY is
  573. still valid.
  574. QuerySamServer():
  575. QueryLSAPolicy():
  576. QueryBuiltinDomain():
  577. QueryAccountDomain():
  578. Query the current handle
  579. QueryAccessSamServer():
  580. QueryAccessLSAPolicy():
  581. QueryAccessBuiltinDomain():
  582. QueryAccessAccountDomain():
  583. Query the access requested for the current
  584. handle. Note that this is not necessarily the
  585. actual access, e.g. if you request MAXIMUM_ALLOWED
  586. this will return MAXIMUM_ALLOWED and not the
  587. actual access.
  588. UpgradeSamServer:
  589. UpgradeLSAPolicy:
  590. UpgradeBuiltinDomain:
  591. UpgradeAccountDomain:
  592. Upgrade the current handle to one with at least
  593. the requested access. If the handle already has
  594. that access this is a no-op. If this fails, the
  595. old handle is left intact and the ADMIN_AUTHORITY
  596. is still valid. Note that the current and requested
  597. access levels are combined with a simple-minded OR,
  598. thus the caller should be careful when the previous
  599. or current request includes MAXIMUM_ALLOWED,
  600. GENERIC_xxx or the like.
  601. QueryApiSession:
  602. Returns a pointer to the API_SESSION established.
  603. This will be NULL if the ADMIN_AUTHORITY was
  604. created for the local machine.
  605. QueryServer
  606. Returns pointer to constructing server
  607. PARENT: BASE
  608. HISTORY:
  609. thomaspa 02/27/92 Created
  610. jonn 07/06/92 Added Replace*
  611. Johnl 09/10/92 Added QueryServer
  612. \**********************************************************/
  613. DLL_CLASS ADMIN_AUTHORITY : public BASE
  614. {
  615. private:
  616. NLS_STR _nlsServerName;
  617. SAM_SERVER * _psamsrv;
  618. SAM_DOMAIN * _psamdomAccount;
  619. SAM_DOMAIN * _psamdomBuiltin;
  620. LSA_POLICY * _plsapol;
  621. API_SESSION * _papisess;
  622. // CODEWORK These access levels should probably be stored with the
  623. // repective handles, not with the ADMIN_AUTHORITY.
  624. ACCESS_MASK _accessSamServer;
  625. ACCESS_MASK _accessLSAPolicy;
  626. ACCESS_MASK _accessBuiltinDomain;
  627. ACCESS_MASK _accessAccountDomain;
  628. public:
  629. ADMIN_AUTHORITY( const TCHAR * pszServerName,
  630. ACCESS_MASK accessAccountDomain = DEF_SAM_DOMAIN_ACCESS,
  631. ACCESS_MASK accessBuiltinDomain = DEF_SAM_DOMAIN_ACCESS,
  632. ACCESS_MASK accessLSA = DEF_LSA_POLICY_ACCESS,
  633. ACCESS_MASK accessServer = DEF_SAM_SERVER_ACCESS,
  634. BOOL fNullSessionOk = FALSE );
  635. ~ADMIN_AUTHORITY();
  636. APIERR ReplaceSamServer(
  637. ACCESS_MASK accessServer = DEF_SAM_SERVER_ACCESS );
  638. APIERR ReplaceLSAPolicy(
  639. ACCESS_MASK accessLSA = DEF_LSA_POLICY_ACCESS );
  640. APIERR ReplaceBuiltinDomain(
  641. ACCESS_MASK accessBuiltinDomain = DEF_SAM_DOMAIN_ACCESS );
  642. APIERR ReplaceAccountDomain(
  643. ACCESS_MASK accessAccountDomain = DEF_SAM_DOMAIN_ACCESS );
  644. SAM_SERVER * QuerySamServer() const;
  645. LSA_POLICY * QueryLSAPolicy() const;
  646. SAM_DOMAIN * QueryBuiltinDomain() const;
  647. SAM_DOMAIN * QueryAccountDomain() const;
  648. ACCESS_MASK QueryAccessSamServer() const;
  649. ACCESS_MASK QueryAccessLSAPolicy() const;
  650. ACCESS_MASK QueryAccessBuiltinDomain() const;
  651. ACCESS_MASK QueryAccessAccountDomain() const;
  652. APIERR UpgradeSamServer(
  653. ACCESS_MASK accessServer = DEF_SAM_SERVER_ACCESS );
  654. APIERR UpgradeLSAPolicy(
  655. ACCESS_MASK accessLSA = DEF_LSA_POLICY_ACCESS );
  656. APIERR UpgradeBuiltinDomain(
  657. ACCESS_MASK accessBuiltinDomain = DEF_SAM_DOMAIN_ACCESS );
  658. APIERR UpgradeAccountDomain(
  659. ACCESS_MASK accessAccountDomain = DEF_SAM_DOMAIN_ACCESS );
  660. const TCHAR * QueryServer( void ) const
  661. { return _nlsServerName.strlen() ? _nlsServerName.QueryPch() : NULL ; }
  662. const API_SESSION * QueryApiSession()
  663. {
  664. return (const API_SESSION *)_papisess;
  665. }
  666. };
  667. #endif // _UINTSAM_HXX_