Source code of Windows XP (NT5)
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.

216 lines
3.8 KiB

  1. // policy.cpp : Implementation of CCRemoteDesktopSystemPolicy
  2. #include "stdafx.h"
  3. #include "rdsgp.h"
  4. CCriticalSection CRemoteDesktopSystemPolicy::m_Lock;
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CRemoteDesktopSystemPolicy
  7. STDMETHODIMP
  8. CRemoteDesktopSystemPolicy::get_AllowGetHelp(
  9. /*[out, retval]*/ BOOL *pVal
  10. )
  11. /*++
  12. Routine Description:
  13. Retrieve where system is allowed to be in 'GetHelp' mode.
  14. Parameters:
  15. pVal : Pointer to BOOL to receive whether system can be
  16. in GetHelp mode.
  17. Returns:
  18. S_OK or error code.
  19. --*/
  20. {
  21. HRESULT hRes = S_OK;
  22. *pVal = TSIsMachinePolicyAllowHelp();
  23. return hRes;
  24. }
  25. STDMETHODIMP
  26. CRemoteDesktopSystemPolicy::put_AllowGetHelp(
  27. /*[in]*/ BOOL Val
  28. )
  29. /*++
  30. Routine Description:
  31. Set Allow to get help on local system, caller must
  32. be Administrator or member of Administrators group.
  33. Parameters:
  34. Val : TRUE to enable GetHelp, FALSE otherwise.
  35. Returns:
  36. S_OK
  37. HRESULT_FROM_WIN32( ERROR_ACCESS_DENIED )
  38. error code.
  39. --*/
  40. {
  41. HRESULT hRes = S_OK;
  42. hRes = ImpersonateClient();
  43. if( SUCCEEDED(hRes) )
  44. {
  45. hRes = HRESULT_FROM_WIN32( ConfigSystemGetHelp( Val ) );
  46. EndImpersonateClient();
  47. }
  48. return hRes;
  49. }
  50. STDMETHODIMP
  51. CRemoteDesktopSystemPolicy::get_RemoteDesktopSharingSetting(
  52. /*[out, retval]*/ REMOTE_DESKTOP_SHARING_CLASS *pLevel
  53. )
  54. /*++
  55. Routine Description:
  56. Retrieve RDS sharing level on local system, function
  57. retrieve setting from Group Policy first, then from
  58. WINSTATION setting.
  59. Parameters:
  60. pLevel : Pointer to REMOTE_DESKTOP_SHARING_CLASS to receive
  61. RDS sharing level.
  62. Returns:
  63. S_OK or error code.
  64. --*/
  65. {
  66. HRESULT hRes = S_OK;
  67. hRes = HRESULT_FROM_WIN32( GetSystemRDSLevel( GetUserTSLogonId(), pLevel ) );
  68. return hRes;
  69. }
  70. STDMETHODIMP
  71. CRemoteDesktopSystemPolicy::put_RemoteDesktopSharingSetting(
  72. /*[in]*/ REMOTE_DESKTOP_SHARING_CLASS Level
  73. )
  74. /*++
  75. Routine Description:
  76. Set machine level RDS sharing level, this level
  77. will override user setting.
  78. Parameters:
  79. Level : new REMOTE_DESKTOP_SHARING_CLASS level
  80. Returns:
  81. S_OK or error code.
  82. Note:
  83. Function depends on platform and setting from Group Policy
  84. and TSCC settings.
  85. --*/
  86. {
  87. HRESULT hRes;
  88. hRes = ImpersonateClient();
  89. if( SUCCEEDED(hRes) )
  90. {
  91. hRes = HRESULT_FROM_WIN32( ConfigSystemRDSLevel(Level) );
  92. EndImpersonateClient();
  93. }
  94. return hRes;
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CRemoteDesktopUserPolicy
  98. STDMETHODIMP
  99. CRemoteDesktopUserPolicy::get_AllowGetHelp(
  100. /*[out, retval]*/ BOOL* pVal
  101. )
  102. /*++
  103. Routine Description:
  104. Retrieve whether currently logon user can
  105. 'GetHelp'
  106. Parameters:
  107. pVal : Pointer to BOOL to receive user's GetHelp setting.
  108. Returns:
  109. S_OK or error code
  110. --*/
  111. {
  112. HRESULT hRes;
  113. CComBSTR bstrUserSid;
  114. hRes = ImpersonateClient();
  115. GetUserSidString( bstrUserSid );
  116. if( SUCCEEDED(hRes) )
  117. {
  118. *pVal = IsUserAllowToGetHelp(GetUserTSLogonId(), (LPCTSTR) CComBSTRtoLPTSTR(bstrUserSid) );
  119. EndImpersonateClient();
  120. }
  121. return hRes;
  122. }
  123. STDMETHODIMP
  124. CRemoteDesktopUserPolicy::get_RemoteDesktopSharingSetting(
  125. /*[out, retval]*/ REMOTE_DESKTOP_SHARING_CLASS* pLevel
  126. )
  127. /*++
  128. Routine Description:
  129. Retrieve currently logon user's desktop sharing level.
  130. Parameters:
  131. pLevel : Pointer to REMOTE_DESKTOP_SHARING_CLASS to receive user's RDS level.
  132. Returns:
  133. S_OK or error code.
  134. --*/
  135. {
  136. HRESULT hRes;
  137. hRes = ImpersonateClient();
  138. if( SUCCEEDED(hRes) )
  139. {
  140. hRes = HRESULT_FROM_WIN32( GetUserRDSLevel(GetUserTSLogonId(), pLevel) );
  141. EndImpersonateClient();
  142. }
  143. return hRes;
  144. }