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.

59 lines
2.5 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: TokenInformation.h
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // Class to get information about either the current thread/process token or
  7. // a specified token.
  8. //
  9. // History: 1999-10-05 vtan created
  10. // 2000-02-01 vtan moved from Neptune to Whistler
  11. // --------------------------------------------------------------------------
  12. #ifndef _TokenInformation_
  13. #define _TokenInformation_
  14. // --------------------------------------------------------------------------
  15. // CTokenInformation
  16. //
  17. // Purpose: This class either uses the given access token or if none is
  18. // given then the thread impersonation token or if that doesn't
  19. // exist then the process token. It duplicates the token so the
  20. // original must be released by the caller. It returns
  21. // information about the access token.
  22. //
  23. // History: 1999-10-05 vtan created
  24. // 2000-02-01 vtan moved from Neptune to Whistler
  25. // --------------------------------------------------------------------------
  26. class CTokenInformation
  27. {
  28. public:
  29. CTokenInformation (HANDLE hToken = NULL);
  30. ~CTokenInformation (void);
  31. PSID GetLogonSID (void);
  32. PSID GetUserSID (void);
  33. bool IsUserTheSystem (void);
  34. bool IsUserAnAdministrator (void);
  35. bool UserHasPrivilege (DWORD dwPrivilege);
  36. const WCHAR* GetUserName (void);
  37. const WCHAR* GetUserDisplayName (void);
  38. static DWORD LogonUser (const WCHAR *pszUsername, const WCHAR *pszDomain, const WCHAR *pszPassword, HANDLE *phToken);
  39. static bool IsSameUser (HANDLE hToken1, HANDLE hToken2);
  40. private:
  41. void GetTokenGroups (void);
  42. void GetTokenPrivileges (void);
  43. private:
  44. HANDLE _hToken,
  45. _hTokenToRelease;
  46. void *_pvGroupBuffer,
  47. *_pvPrivilegeBuffer,
  48. *_pvUserBuffer;
  49. WCHAR *_pszUserLogonName,
  50. *_pszUserDisplayName;
  51. };
  52. #endif /* _TokenInformation_ */