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.

60 lines
2.0 KiB

  1. /*****************************************************************************/
  2. /* Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved /
  3. /*****************************************************************************/
  4. /*
  5. * CTokenPrivilege.h - header file for CTokenPrivilege class
  6. *
  7. * Created: 12-14-1997 by Sanjeev Surati
  8. * (based on classes from Windows NT Security by Nik Okuntseff)
  9. */
  10. #if !defined __CTOKENPRIVILEGE_H__
  11. #define __CTOKENPRIVILEGE_H__
  12. ////////////////////////////////////////////////////////////////
  13. //
  14. // Class: CTokenPrivilege
  15. //
  16. // This class is intended to provide a wrapper for basic
  17. // Windows NT token privilege enabling/disabling. In order
  18. // to perform certain operations on a Windows NT box, it is
  19. // often necessary to not only have certain privileges, but
  20. // to turn those privileges on and off as needed (as certain
  21. // privileges may be available but not enabled by default).
  22. // The class needs an access token to work correctly. A
  23. // user can either pass us one, or we will try to obtain one.
  24. // First, we try to open a thread token (set by Impersonation),
  25. // and if that fails, then we attempt to get the process
  26. // level token.
  27. //
  28. ////////////////////////////////////////////////////////////////
  29. class CTokenPrivilege
  30. {
  31. // Constructors and destructor
  32. public:
  33. CTokenPrivilege( LPCTSTR pszPrivilegeName, HANDLE hAccessToken = INVALID_HANDLE_VALUE, LPCTSTR pszSystemName = NULL );
  34. ~CTokenPrivilege( void );
  35. void GetPrivilegeName( CHString& strPrivilegeName );
  36. DWORD GetPrivilegeDisplayName( CHString& strDisplayName, LPDWORD pdwLanguageId );
  37. DWORD Enable( bool fEnable = TRUE );
  38. // Private data members
  39. private:
  40. CHString m_strPrivilegeName;
  41. CHString m_strSystemName;
  42. HANDLE m_hAccessToken;
  43. bool m_fClearToken;
  44. LUID m_luid;
  45. };
  46. inline void CTokenPrivilege::GetPrivilegeName( CHString& strPrivilegeName )
  47. {
  48. m_strPrivilegeName = strPrivilegeName;
  49. }
  50. #endif // __CTokenPrivilege_H__