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.

87 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: usradmn.hxx
  7. //
  8. // Contents: Class definition for CUsrAdmn Class
  9. //
  10. // History: 2/20/97 Narindk Created
  11. //
  12. // Notes: This class maybe used to create and login as a non-admin user
  13. // whereever required and revert to admin user as reqd. Also
  14. // has functions to determine if the currently logged in user
  15. // is an admin or non-admin user. This class is for use only on
  16. // Windows NT systems. The sample usage of this class is in
  17. // aspects of testing where you want to check the behaviour of
  18. // an ordinary user (without administrator privileges) with
  19. // respect to certain features of system, e.g. security aspects.
  20. // You must be logged in as an administrator user, holding the
  21. // advanced SE_TCB_PRIVILEGE (act as part of operating system).
  22. // To do that, run user manager, then select Policies - User
  23. // Rights. Check the Show Advanced Rights option. Select the
  24. // "Act as part of operating System right" and select add button
  25. // to add the current admin user for this right. Log off and log
  26. // back in. While running the test suite, then in your tests,
  27. // you could use this class to automate cases where an ordinary
  28. // user is required for testing.
  29. //
  30. //----------------------------------------------------------------------------
  31. #ifndef _USRADMN_HXX_
  32. #define _USRADMN_HXX_
  33. //+------------------------------------------------------------------
  34. //
  35. // Class: CUsrAdmn
  36. //
  37. // Functions: CUsrAdmn::CUsrAdmn (public)
  38. // CUsrAdmn::~CUsrAdmn (public)
  39. // CUsrAdmn::BecomeUser (public) - Logs in as ordinary (non admin
  40. // user
  41. // CUsrAdmn::BecomeAdmin (public) - Reverts back to the orginal
  42. // admin user
  43. // CUsrAdmn::IsAdmin (public) - Checks if the current user is
  44. // an admin user
  45. // CUsrAdmn::CreateTemporaryUser (private) - Creates a temporary
  46. // user
  47. // CUsrAdmn::VerifyProcessPrivileges (private) - Verifies if the
  48. // admin user has SE_TCB_PRIVI
  49. // LEGE
  50. //
  51. // Data Members: m_tempUserInfo
  52. // m_hLogonToken
  53. //
  54. // History: Narindk 2/20/97 Created
  55. //
  56. //+------------------------------------------------------------------
  57. class CUsrAdmn
  58. {
  59. public:
  60. CUsrAdmn();
  61. ~CUsrAdmn();
  62. HRESULT BecomeUser();
  63. HRESULT BecomeAdmin();
  64. HRESULT IsAdmin();
  65. private:
  66. USER_INFO_1 m_tempUserInfo;
  67. HANDLE m_hLogonToken;
  68. HRESULT VerifyProcessPrivileges();
  69. HRESULT CreateTemporaryUser();
  70. };
  71. #endif //_USRADMN_HXX_