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.

325 lines
11 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*********************************************************************************************
  3. *
  4. *
  5. * Module Name:
  6. *
  7. * CfgComp.h
  8. *
  9. * Abstract:
  10. * This contains the declaration for the functions in CfgBkEnd.
  11. *
  12. *
  13. * Author: Arathi Kundapur: a-akunda
  14. *
  15. *
  16. * Revision:
  17. *
  18. *
  19. ************************************************************************************************/
  20. #ifndef __CFGCOMP_H_
  21. #define __CFGCOMP_H_
  22. #include "resource.h" // main symbols
  23. #include "PtrArray.h" // Added by ClassView
  24. extern HINSTANCE g_hInstance;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CCfgComp
  27. class ATL_NO_VTABLE CCfgComp :
  28. public CComObjectRootEx<CComSingleThreadModel>,
  29. public CComCoClass<CCfgComp, &CLSID_CfgComp>,
  30. public ICfgComp,
  31. public ISettingsComp ,
  32. public IUserSecurity
  33. {
  34. public:
  35. CCfgComp()
  36. {
  37. m_bInitialized = FALSE;
  38. m_bAdmin = FALSE;
  39. lstrcpy( m_szConsole , L"Console" );
  40. /*
  41. LoadString(g_hInstance, IDS_SYSTEM_CONSOLE_NAME,
  42. m_szConsole, WINSTATIONNAME_LENGTH );
  43. */
  44. }
  45. ~CCfgComp()
  46. {
  47. UnInitialize();
  48. }
  49. DECLARE_REGISTRY_RESOURCEID(IDR_CFGCOMP)
  50. DECLARE_NOT_AGGREGATABLE(CCfgComp)
  51. BEGIN_COM_MAP(CCfgComp)
  52. COM_INTERFACE_ENTRY(ICfgComp)
  53. COM_INTERFACE_ENTRY(ISettingsComp)
  54. COM_INTERFACE_ENTRY(IUserSecurity)
  55. END_COM_MAP()
  56. // ICfgComp Methods
  57. public:
  58. // STDMETHOD(SetDefaultSecurity)(ULONG Offset);
  59. // STDMETHOD(GetDefaultSecurity)(ULONG * pDefaultSecurity);
  60. STDMETHOD(SetInternetConLic)(BOOL bInternetConLic , PDWORD );
  61. STDMETHOD(GetInternetConLic)(BOOL * pbInternetConLic , PDWORD );
  62. STDMETHOD(SetLicensingMode)(ULONG ulMode , PDWORD, PDWORD );
  63. STDMETHOD(GetLicensingMode)(ULONG *pulMode , PDWORD );
  64. STDMETHOD(GetLicensingModeInfo)(ULONG ulMode , WCHAR **pwszName, WCHAR **pwszDescription, PDWORD );
  65. STDMETHOD(GetLicensingModeList)(ULONG *pcModes , ULONG **prgulModes, PDWORD );
  66. STDMETHOD(SetUseTempDirPerSession)(BOOL bTempDirPerSession);
  67. STDMETHOD(GetUseTempDirPerSession)(BOOL * pbTempDir);
  68. STDMETHOD(SetDelDirsOnExit)(BOOL bDelDirsOnExit);
  69. STDMETHOD(GetDelDirsOnExit)(BOOL * pDelDirsOnExit);
  70. // STDMETHOD(SetCachedSessions)(DWORD dCachedSessions);
  71. STDMETHOD_(BOOL, IsAsyncDeviceAvailable)(LPCTSTR pDeviceName);
  72. STDMETHOD(DeleteWS)(PWINSTATIONNAME pWs);
  73. STDMETHOD(IsNetWorkConnectionUnique)(WCHAR * WdName, WCHAR * PdName, ULONG LanAdapter , BOOL * pUnique);
  74. STDMETHOD(GetDefaultUserConfig)(WCHAR * WdName,long * pSize,PUSERCONFIG* ppUser);
  75. STDMETHOD(CreateNewWS)(WS WinstationInfo,long UserCnfgSize, PUSERCONFIG pUserConfig, PASYNCCONFIGW pAsyncConfig);
  76. STDMETHOD(GetWSInfo)(PWINSTATIONNAME pWSName, long * Size, WS **ppWS);
  77. STDMETHOD(UpDateWS)( PWS , DWORD Data , PDWORD, BOOLEAN bPerformMerger );
  78. STDMETHOD(GetDefaultSecurityDescriptor)(long * pSize,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  79. STDMETHOD(IsSessionReadOnly)(BOOL * pReadOnly);
  80. STDMETHOD(RenameWinstation)(PWINSTATIONNAMEW pOldWinstation, PWINSTATIONNAMEW pNewWinstation);
  81. STDMETHOD(EnableWinstation)(PWINSTATIONNAMEW pWSName, BOOL fEnable);
  82. STDMETHOD(SetUserConfig)(PWINSTATIONNAMEW pWsName, ULONG size, PUSERCONFIG pUserConfig , PDWORD );
  83. STDMETHOD(GetLanAdapterList)(WCHAR * pdName, ULONG * pNumAdapters,ULONG * pSize,WCHAR ** ppData);
  84. STDMETHOD(GetLanAdapterList2)(WCHAR * pdName, ULONG * pNumAdapters, PGUIDTBL *);
  85. STDMETHOD( BuildGuidTable )( PGUIDTBL * , int , WCHAR * );
  86. STDMETHOD(GetTransportTypes)(WCHAR * Name, NameType Type,ULONG *pNumWd,ULONG * pSize, WCHAR **ppData);
  87. STDMETHOD(IsWSNameUnique)(PWINSTATIONNAMEW pWSName,BOOL * pUnique);
  88. STDMETHOD(GetWdTypeList)(ULONG *pNumWd,ULONG * pSize, WCHAR **ppData);
  89. STDMETHOD(GetWinstationList)(ULONG * NumWinstations, ULONG * Size, PWS * ppWS);
  90. STDMETHOD(Initialize)();
  91. STDMETHOD(GetEncryptionLevels)(WCHAR * pName, NameType Type,ULONG * pNumEncryptionLevels,Encryption ** ppEncryption);
  92. STDMETHOD(GetUserConfig)(PWINSTATIONNAMEW pWsName, long * pSize,PUSERCONFIG * ppUser, BOOLEAN bPerformMerger);
  93. STDMETHOD(SetSecurityDescriptor)(PWINSTATIONNAMEW pWsName,DWORD Size,PSECURITY_DESCRIPTOR pSecurityDescriptor);
  94. STDMETHOD(GetSecurityDescriptor)(PWINSTATIONNAMEW pWSName,long * pSize,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  95. STDMETHOD( ForceUpdate )( void );
  96. STDMETHOD( Refresh )( void );
  97. STDMETHOD( GetWdType )( PWDNAMEW , PULONG );
  98. STDMETHOD( GetTransportType )( WCHAR * , WCHAR * , DWORD * );
  99. STDMETHOD( IsAsyncUnique )( WCHAR * , WCHAR * , BOOL * );
  100. STDMETHOD( SetAsyncConfig )( WCHAR * , NameType , PASYNCCONFIGW , PDWORD );
  101. STDMETHOD( GetAsyncConfig )( WCHAR * , NameType , PASYNCCONFIGW );
  102. STDMETHOD( GetDeviceList )( WCHAR * , NameType , ULONG * , LPBYTE * );
  103. STDMETHOD( GetConnTypeName )( int , WCHAR * );
  104. STDMETHOD( GetHWReceiveName )( int , WCHAR * );
  105. STDMETHOD( GetHWTransmitName )( int , WCHAR * );
  106. STDMETHOD( GetModemCallbackString )( int , WCHAR * );
  107. STDMETHOD( GetCaps )( WCHAR * , ULONG * );
  108. STDMETHOD( QueryLoggedOnCount )( WCHAR * , LONG * );
  109. STDMETHOD( GetNumofWinStations )(WCHAR *,WCHAR *, PULONG );
  110. STDMETHOD( UpdateSessionDirectory )( PDWORD );
  111. STDMETHOD( GetColorDepth )( /* in */ PWINSTATIONNAMEW pWs, /* out */ BOOL * , /* out */ PDWORD );
  112. STDMETHOD( SetColorDepth )( /* in */ PWINSTATIONNAMEW pWs, /* in */ BOOL, /* out */ PDWORD );
  113. STDMETHOD( GetKeepAliveTimeout )( /* in */ PWINSTATIONNAMEW pWs, /* out */ BOOL * , /* out */ PDWORD );
  114. STDMETHOD( SetKeepAliveTimeout )( /* in */ PWINSTATIONNAMEW pWs, /* in */ BOOL, /* out */ PDWORD );
  115. STDMETHOD( GetProfilePath )( /* out */ BSTR * , /* out */ PDWORD );
  116. STDMETHOD( SetProfilePath )( /* in */ BSTR , /* out */ PDWORD );
  117. STDMETHOD( GetHomeDir )( /* out */ BSTR * , /* out */ PDWORD );
  118. STDMETHOD( SetHomeDir )( /* in */ BSTR , /* out */ PDWORD );
  119. //ISettingComp Methods
  120. // STDMETHOD( GetCachedSessions )(DWORD * );
  121. STDMETHOD( SetActiveDesktopState )( /* in */ BOOL , /* out */ PDWORD );
  122. STDMETHOD( GetActiveDesktopState )( /* out */ PBOOL , /* out */ PDWORD );
  123. STDMETHOD( GetTermSrvMode )( /* out */ PDWORD , /* out */ PDWORD );
  124. STDMETHOD( GetWdKey )( /* in */ WCHAR * , /* out , string */ WCHAR * );
  125. STDMETHOD( GetUserPerm )( /* out */ BOOL * , /* out */ DWORD * );
  126. STDMETHOD( SetUserPerm )( /* in */ BOOL , /* out */ PDWORD );
  127. STDMETHOD( GetSalemHelpMode )( /* out */ BOOL *, /* out */ PDWORD );
  128. STDMETHOD( SetSalemHelpMode )( /* in */ BOOL, /* out */ PDWORD );
  129. STDMETHOD( GetDenyTSConnections )( /* out */ BOOL * , /* out */ PDWORD );
  130. STDMETHOD( SetDenyTSConnections )( /* in */ BOOL, /* out */ PDWORD );
  131. STDMETHOD( GetSingleSessionState )( /* out */ BOOL * , /* out */ PDWORD );
  132. STDMETHOD( SetSingleSessionState )( /* in */ BOOL, /* out */ PDWORD );
  133. STDMETHOD( GetTimeZoneRedirection )( /* out */ BOOL * , /* out */ PDWORD );
  134. STDMETHOD( SetTimeZoneRedirection )( /* in */ BOOL, /* out */ PDWORD );
  135. STDMETHOD( GetDisableForcibleLogoff )( /* out */ BOOL * , /* out */ PDWORD );
  136. STDMETHOD( SetDisableForcibleLogoff )( /* in */ BOOL, /* out */ PDWORD );
  137. //IUserSecurity Methods
  138. STDMETHOD( ModifyUserAccess )( /* in */ WCHAR *pwszWinstaName ,
  139. /* in */ WCHAR *pwszAccountName ,
  140. /* in */ DWORD dwMask ,
  141. /* in */ BOOL fDel ,
  142. /* in */ BOOL fAllow ,
  143. /* in */ BOOL fNew ,
  144. /* in */ BOOL fAuditing ,
  145. /* out*/ PDWORD pdwStatus );
  146. STDMETHOD( ModifyDefaultSecurity )( /* in */ WCHAR *pwszWinstaName ,
  147. /* in */ WCHAR *pwszAccountName ,
  148. /* in */ DWORD dwMask ,
  149. /* in */ BOOL fDel ,
  150. /* in */ BOOL fAllow ,
  151. /* in */ BOOL fAuditing ,
  152. /* out*/ PDWORD pdwStatus );
  153. STDMETHOD( GetUserPermList )( /* in */ WCHAR *pwszWinstaName ,
  154. /* out*/ PDWORD pcbItems ,
  155. /* out*/ PUSERPERMLIST *ppUserPermList,
  156. /* in */ BOOL fAudit );
  157. private:
  158. // PSECURITY_DESCRIPTOR ReadSecurityDescriptor(ULONG index);
  159. // HRESULT SetDefaultSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurity);
  160. DWORD
  161. RemoveUserEntriesInACL(
  162. LPCTSTR pszUserName,
  163. PACL pAcl,
  164. PACL* ppNewAcl
  165. );
  166. DWORD
  167. GetUserSid(
  168. LPCTSTR pszUserName,
  169. PSID* ppUserSid
  170. );
  171. HRESULT
  172. SetSecurityDescriptor(
  173. BOOL bDefaultSecurity,
  174. PWINSTATIONNAMEW pWsName,
  175. DWORD Size,
  176. PSECURITY_DESCRIPTOR pSecurityDescriptor
  177. );
  178. BOOL
  179. ValidDefaultSecurity(
  180. const WCHAR* pwszName
  181. );
  182. HRESULT
  183. ModifyWinstationSecurity(
  184. BOOL bDefaultSecurity,
  185. WCHAR *pwszWinstaName ,
  186. WCHAR *pwszAccountName ,
  187. DWORD dwMask ,
  188. BOOL fDel ,
  189. BOOL fAllow ,
  190. BOOL fNew ,
  191. BOOL fAuditing ,
  192. PDWORD pdwStatus
  193. );
  194. void DeleteWDArray();
  195. STDMETHODIMP FillWdArray();
  196. STDMETHODIMP FillWsArray();
  197. STDMETHODIMP InsertInWSArray( PWINSTATIONNAMEW pWSName,PWINSTATIONCONFIG2W pWSConfig,
  198. PWS * ppObject );
  199. void DeleteWSArray();
  200. PWD GetWdObject(PWDNAMEW pWdName);
  201. PWS GetWSObject(WINSTATIONNAMEW WSName);
  202. STDMETHOD(UnInitialize)();
  203. BOOL GetResourceStrings( int * , int , WCHAR * );
  204. HRESULT GetWinStationSecurity(BOOL bDefault, PWINSTATIONNAMEW pWSName,PSECURITY_DESCRIPTOR *ppSecurityDescriptor);
  205. //Function borrowed from security.c in tscfg project
  206. DWORD ValidateSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor);
  207. // BOOL CompareSD(PSECURITY_DESCRIPTOR pSd1,PSECURITY_DESCRIPTOR pSd2);
  208. BOOL RegServerAccessCheck(REGSAM samDesired);
  209. void GetPdConfig( WDNAME WdKey,WINSTATIONCONFIG2W& WsConfig);
  210. void VerifyGuidsExistence( PGUIDTBL * , int , WCHAR *);
  211. HRESULT AdjustLanaId( PGUIDTBL * , int , int , PDWORD , PDWORD , int* , int );
  212. CPtrArray m_WDArray;
  213. BOOL m_bInitialized;
  214. BOOL m_bAdmin;
  215. CPtrArray m_WSArray;
  216. TCHAR m_szConsole[WINSTATIONNAME_LENGTH + 1];
  217. };
  218. #endif //__CFGCOMP_H_