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.

116 lines
3.2 KiB

  1. #ifndef USERINFO_H_INCLUDED
  2. #define USERINFO_H_INCLUDED
  3. class CUserInfo
  4. {
  5. public:
  6. // Typedefs
  7. enum USERTYPE
  8. {
  9. LOCALUSER = 0,
  10. DOMAINUSER,
  11. GROUP
  12. };
  13. // Group pseudonym tells any functions that may change a user's group that the
  14. // user selected an option button that says something like "standard user" or
  15. // "restricted user" instead of selecting the real group name from a list.
  16. // In this case, the group change functions may display custom error messages that
  17. // mention "standard user access" instead of "power users group", for example.
  18. enum GROUPPSEUDONYM
  19. {
  20. RESTRICTED = 0,
  21. STANDARD,
  22. USEGROUPNAME
  23. };
  24. public:
  25. // Functions
  26. CUserInfo();
  27. ~CUserInfo();
  28. HRESULT Load(PSID psid, BOOL fLoadExtraInfo = NULL);
  29. HRESULT Reload(BOOL fLoadExtraInfo = NULL);
  30. HRESULT Create(HWND hwndError, GROUPPSEUDONYM grouppseudonym);
  31. HRESULT UpdateUsername(LPTSTR pszNewUsername);
  32. HRESULT UpdateFullName(LPTSTR pszFullName);
  33. HRESULT UpdatePassword(BOOL* pfBadPWFormat);
  34. HRESULT UpdateGroup(HWND hwndError, LPTSTR pszGroup, GROUPPSEUDONYM grouppseudonym);
  35. HRESULT UpdateDescription(LPTSTR pszDescription);
  36. HRESULT Remove();
  37. HRESULT InitializeForNewUser();
  38. HRESULT GetExtraUserInfo();
  39. HRESULT SetUserType();
  40. HRESULT SetLocalGroups();
  41. void HidePassword();
  42. void RevealPassword();
  43. void ZeroPassword();
  44. public:
  45. // Data
  46. // Index of this user's icon (local, domain, group)
  47. USERTYPE m_userType;
  48. TCHAR m_szUsername[MAX_USER + 1];
  49. TCHAR m_szDomain[MAX_DOMAIN + 1];
  50. TCHAR m_szComment[MAXCOMMENTSZ];
  51. TCHAR m_szFullName[MAXCOMMENTSZ];
  52. // Only if we're creating a new user:
  53. TCHAR m_szPasswordBuffer[MAX_PASSWORD + 1];
  54. UNICODE_STRING m_Password;
  55. UCHAR m_Seed;
  56. // Room for AT LEAST two group names plus a ';' a ' ' and a '\0'
  57. TCHAR m_szGroups[MAX_GROUP * 2 + 3];
  58. // The user's SID
  59. PSID m_psid;
  60. SID_NAME_USE m_sUse;
  61. // Is the account disabled
  62. BOOL m_fAccountDisabled;
  63. // Have we read the user's full name and comment yet?
  64. BOOL m_fHaveExtraUserInfo;
  65. private:
  66. // Helpers
  67. HRESULT RemoveFromLocalGroups();
  68. HRESULT ChangeLocalGroups(HWND hwndError, GROUPPSEUDONYM grouppseudonym);
  69. HRESULT SetAccountDisabled();
  70. };
  71. class CUserListLoader
  72. {
  73. public:
  74. CUserListLoader();
  75. ~CUserListLoader();
  76. HRESULT Initialize(HWND hwndUserListPage);
  77. void EndInitNow() {m_fEndInitNow = TRUE;}
  78. BOOL InitInProgress()
  79. {return (WAIT_OBJECT_0 != WaitForSingleObject(m_hInitDoneEvent, 0));}
  80. private:
  81. HRESULT UpdateFromLocalGroup(LPWSTR szLocalGroup);
  82. HRESULT AddUserInformation(PSID psid);
  83. BOOL HasUserBeenAdded(PSID psid);
  84. static DWORD WINAPI InitializeThread(LPVOID pvoid);
  85. private:
  86. // Data
  87. HWND m_hwndUserListPage;
  88. HANDLE m_hInitDoneEvent;
  89. BOOL m_fEndInitNow;
  90. CDPA<CUserInfo> m_dpaAddedUsers;
  91. };
  92. // User info functions
  93. BOOL UserAlreadyHasPermission(CUserInfo* pUserInfo, HWND hwndMsgParent);
  94. #endif // !USERINFO_H_INCLUDED