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.

194 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. HelpAcc.h
  5. Abstract:
  6. Declaration of the HelpAssistantAccount structure
  7. Author:
  8. HueiWang 2/17/2000
  9. --*/
  10. #ifndef __HELPASSISTANTACCOUNT_H__
  11. #define __HELPASSISTANTACCOUNT_H__
  12. #include "stdafx.h"
  13. #include <lm.h>
  14. #include <wtsapi32.h>
  15. #include <winsta.h>
  16. #include "helper.h"
  17. #define MAX_USERNAME_LENGTH LM20_UNLEN
  18. //
  19. // Default Help Assistant account name
  20. //
  21. #define HELPASSISTANTACCOUNT_NAME SALEMHELPASSISTANTACCOUNT_NAME
  22. //
  23. // LSA key to store help assistant account password and SID
  24. //
  25. #define HELPASSISTANTACCOUNT_PASSWORDKEY SALEMHELPASSISTANTACCOUNT_PASSWORDKEY
  26. #define HELPASSISTANTACCOUNT_SIDKEY SALEMHELPASSISTANTACCOUNT_SIDKEY
  27. #define HELPASSISTANTACCOUNT_EMPTYPASSWORD L""
  28. // number of retry with to generate unique HelpAssistant account name
  29. #define MAX_UNIQUENAME_RETRY 25
  30. #if __WIN9XBUILD__
  31. // pre-define USER SID for Win9x box.
  32. #define WIN9X_USER_SID _TEXT("1-1-1-1-1-1")
  33. #endif
  34. #define RDSADDINEXECNAME _TEXT("rdsaddin.exe")
  35. typedef BOOL (WINAPI* PWTSSetUserConfigW)(
  36. IN LPWSTR pServerName,
  37. IN LPWSTR pUserName,
  38. IN WTS_CONFIG_CLASS WTSConfigClass,
  39. IN LPWSTR pBuffer,
  40. IN DWORD DataLength
  41. );
  42. #define REGVALUE_PERSONAL_WKS_TSSETTING _TEXT("TS Connection")
  43. typedef struct __HelpAssistantAccount
  44. {
  45. private:
  46. static CCriticalSection gm_HelpAccountCS;
  47. static DWORD gm_dwAccErrCode;
  48. HRESULT
  49. GetHelpAccountScript(
  50. CComBSTR& bstrScript
  51. );
  52. HRESULT
  53. CacheHelpAccountSID();
  54. HRESULT
  55. LookupHelpAccountSid(
  56. IN LPTSTR pszAccName,
  57. OUT PSID* ppSid,
  58. OUT DWORD* pcbSid
  59. );
  60. HRESULT
  61. ConfigHelpAccountTSSettings(
  62. IN LPTSTR pszAccName,
  63. IN LPTSTR pszInitProgram
  64. );
  65. DWORD
  66. EnableAccountRights(
  67. BOOL bEnable,
  68. DWORD dwNumRights,
  69. LPTSTR* rights
  70. );
  71. public:
  72. static CComBSTR gm_bstrHelpAccountPwd;
  73. static CComBSTR gm_bstrHelpAccountName;
  74. static CComBSTR gm_bstrHelpAccountDomain;
  75. static PBYTE gm_pbHelpAccountSid;
  76. static DWORD gm_cbHelpAccountSid;
  77. ~__HelpAssistantAccount()
  78. {
  79. FreeMemory(gm_pbHelpAccountSid);
  80. }
  81. HRESULT
  82. Initialize(
  83. BOOL bVerifyPassword = TRUE
  84. );
  85. BOOL
  86. IsValid()
  87. {
  88. return ERROR_SUCCESS == gm_dwAccErrCode;
  89. }
  90. HRESULT
  91. DeleteHelpAccount();
  92. HRESULT
  93. CreateHelpAccount(
  94. LPCTSTR pszPassword = NULL
  95. );
  96. HRESULT
  97. SetupHelpAccountTSSettings( BOOL bForce = FALSE );
  98. HRESULT
  99. SetupHelpAccountTSRights(
  100. IN BOOL bDel,
  101. IN BOOL bEnable,
  102. IN BOOL bDelExisting,
  103. IN DWORD dwPermissions
  104. );
  105. HRESULT
  106. ResetHelpAccountPassword(
  107. LPCTSTR pszPassword = NULL
  108. );
  109. HRESULT
  110. GetHelpAccountNameEx( CComBSTR& bstrValue )
  111. {
  112. DWORD dwStatus = ERROR_SUCCESS;
  113. bstrValue = gm_bstrHelpAccountName;
  114. if( 0 == bstrValue.Length() )
  115. {
  116. MYASSERT(0 == bstrValue.Length());
  117. dwStatus = ERROR_INTERNAL_ERROR;
  118. }
  119. return HRESULT_FROM_WIN32( dwStatus );
  120. }
  121. BOOL
  122. IsAccountHelpAccount(
  123. IN PBYTE pbSid,
  124. IN DWORD cbSid
  125. );
  126. HRESULT
  127. EnableRemoteInteractiveRight(
  128. BOOL bEnable
  129. );
  130. HRESULT
  131. EnableHelpAssistantAccount(
  132. BOOL bEnable
  133. );
  134. } HelpAssistantAccount;
  135. #endif