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.

172 lines
4.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. lmoesu.hxx
  7. This file contains the class declarations for the SAM_USER_ENUM
  8. class and its associated iterator classes.
  9. FILE HISTORY:
  10. KeithMo 13-Apr-1992 Created for the Server Manager.
  11. */
  12. #ifndef _LMOESU_HXX_
  13. #define _LMOESU_HXX_
  14. #ifndef WIN32
  15. #error NT enumerator requires WIN32!
  16. #endif // WIN32
  17. #include "lmoersm.hxx"
  18. #include "uintsam.hxx"
  19. /*************************************************************************
  20. NAME: SAM_USER_ENUM
  21. SYNOPSIS: The SAM_USER_ENUM enumerator is used to enumerate
  22. the users in a SAM domain.
  23. INTERFACE: SAM_USER_ENUM - Class constructor.
  24. ~SAM_USER_ENUM - Class destructor.
  25. CallAPI - Invokes the enumeration API.
  26. PARENT: LM_RESUME_ENUM
  27. HISTORY:
  28. KeithMo 13-Apr-1992 Created for the Server Manager.
  29. **************************************************************************/
  30. DLL_CLASS SAM_USER_ENUM : public LM_RESUME_ENUM
  31. {
  32. private:
  33. //
  34. // The SamEnumerateUsersInDomain() resume key.
  35. //
  36. SAM_ENUMERATE_HANDLE _ResumeKey;
  37. //
  38. // This SAM_DOMAIN object represents the target server on which
  39. // the enumeration will be performed.
  40. //
  41. const SAM_DOMAIN * _psamdomain;
  42. //
  43. // This is a wrapper around the SAM_RID_ENUMERATION structure
  44. // (as returned by SAM_DOMAIN::EnumerateUsers).
  45. //
  46. SAM_RID_ENUMERATION_MEM _samrem;
  47. //
  48. // This is the account control mask used to filter the
  49. // enumeration.
  50. //
  51. ULONG _lAccountControl;
  52. //
  53. // This virtual callback invokes the SamEnumerateUsersInDomain() API
  54. // through SAM_DOMAIN::EnumerateUsers().
  55. //
  56. virtual APIERR CallAPI( BOOL fRestartEnum,
  57. BYTE ** ppbBuffer,
  58. UINT * pcEntriesRead );
  59. protected:
  60. //
  61. // Destroy the buffer with ::SamFreeMemory().
  62. //
  63. virtual VOID FreeBuffer( BYTE ** ppbBuffer );
  64. public:
  65. //
  66. // Usual constructor/destructor goodies.
  67. //
  68. SAM_USER_ENUM( const SAM_DOMAIN * psamdomain,
  69. ULONG lAccountControl,
  70. BOOL fKeepBuffers = FALSE );
  71. ~SAM_USER_ENUM( VOID );
  72. }; // class SAM_USER_ENUM
  73. class SAM_USER_ITER; // Forward reference.
  74. /*************************************************************************
  75. NAME: SAM_USER_ENUM_OBJ
  76. SYNOPSIS: This is basically the return type from the
  77. SAM_USER_ENUM_ITER iterator.
  78. INTERFACE: QueryUnicodeUserName - Returns a UNICODE_STRING *
  79. for the user name.
  80. QueryUserName - Also returns the user name,
  81. but stores it in an NLS_STR.
  82. QueryUserRID - Returns the user's RID.
  83. PARENT: ENUM_OBJ_BASE
  84. HISTORY:
  85. KeithMo 13-Apr-1992 Created for the Server Manager.
  86. **************************************************************************/
  87. DLL_CLASS SAM_USER_ENUM_OBJ : public ENUM_OBJ_BASE
  88. {
  89. public:
  90. //
  91. // Provide properly-casted buffer Query/Set methods.
  92. //
  93. const SAM_RID_ENUMERATION * QueryBufferPtr( VOID ) const
  94. { return (const SAM_RID_ENUMERATION *)ENUM_OBJ_BASE::QueryBufferPtr(); }
  95. VOID SetBufferPtr( const SAM_RID_ENUMERATION * pBuffer )
  96. { ENUM_OBJ_BASE::SetBufferPtr( (const BYTE *)pBuffer ); }
  97. //
  98. // Accessors.
  99. //
  100. const UNICODE_STRING * QueryUnicodeUserName( VOID ) const
  101. { return &(QueryBufferPtr()->Name); }
  102. APIERR QueryUserName( NLS_STR * pnls ) const
  103. {
  104. ASSERT( pnls != NULL );
  105. ASSERT( pnls->QueryError() == NERR_Success );
  106. return pnls->MapCopyFrom( QueryUnicodeUserName()->Buffer,
  107. QueryUnicodeUserName()->Length );
  108. }
  109. DECLARE_ENUM_ACCESSOR( QueryUserRID, ULONG, RelativeId );
  110. }; // class SAM_USER_ENUM_OBJ
  111. DECLARE_LM_RESUME_ENUM_ITER_OF( SAM_USER, SAM_RID_ENUMERATION );
  112. #endif // _LMOESU_HXX_