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.

79 lines
2.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CImpersonateUser.h
  7. //
  8. // Description:
  9. // Header file for CImpersonateUser class.
  10. //
  11. // The CImpersonateUser class begins impersonating a user in its
  12. // constructor and automatically reverts to the original token in
  13. // the destructor.
  14. //
  15. // Maintained By:
  16. // Vij Vasu (Vvasu) 16-MAY-2000
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. // Make sure that this file is included only once per compile path.
  20. #pragma once
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Include Files
  23. //////////////////////////////////////////////////////////////////////////////
  24. //////////////////////////////////////////////////////////////////////////////
  25. //++
  26. //
  27. // class CImpersonateUser
  28. //
  29. // Description:
  30. // The CImpersonateUser class begins impersonating a user in its
  31. // constructor and automatically reverts to the original token in
  32. // the destructor.
  33. //
  34. //--
  35. //////////////////////////////////////////////////////////////////////////////
  36. class CImpersonateUser
  37. {
  38. public:
  39. //////////////////////////////////////////////////////////////////////////
  40. // Constructors and destructors
  41. //////////////////////////////////////////////////////////////////////////
  42. // Construtor. Start impersonating the user whose token is passed in.
  43. CImpersonateUser( HANDLE hUserToken );
  44. // Destructor. Revert to the original token.
  45. ~CImpersonateUser() throw();
  46. private:
  47. //////////////////////////////////////////////////////////////////////////
  48. // Private member functions
  49. //////////////////////////////////////////////////////////////////////////
  50. // Copy constructor
  51. CImpersonateUser( const CImpersonateUser & );
  52. // Assignment operator
  53. const CImpersonateUser & operator =( const CImpersonateUser & );
  54. //////////////////////////////////////////////////////////////////////////
  55. // Private member data
  56. //////////////////////////////////////////////////////////////////////////
  57. // Handle to the token for the thread before the impersonation began.
  58. HANDLE m_hThreadToken;
  59. // Indicates if this thread was already impersonating a client when this
  60. // object was constructed.
  61. bool m_fWasImpersonating;
  62. }; //*** class CImpersonateUser