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.

446 lines
15 KiB

  1. // virsvr.h : Declaration of the CSmtpAdminVirtualServer
  2. #include "resource.h" // main symbols
  3. /////////////////////////////////////////////////////////////////////////////
  4. // Dependencies:
  5. #include "metafact.h"
  6. #include "cmultisz.h"
  7. #include "binding.h"
  8. #include "rtsrc.h"
  9. class CTcpAccess;
  10. // Administrator ACL:
  11. HRESULT AclToAdministrators ( LPCTSTR strServer, PSECURITY_DESCRIPTOR pSDRelative, SAFEARRAY ** ppsaAdmins );
  12. HRESULT AdministratorsToAcl ( LPCTSTR strServer, SAFEARRAY * psaAdmins, PSECURITY_DESCRIPTOR* ppSD, DWORD * pcbSD );
  13. static HRESULT SidToString ( PSID pSID, BSTR * pStr );
  14. static HRESULT StringToSid ( LPCWSTR strSystemName, LPWSTR str, PSID * ppSID );
  15. /////////////////////////////////////////////////////////////////////////////
  16. // smtpadm
  17. class CSmtpAdminVirtualServer :
  18. public CComDualImpl<ISmtpAdminVirtualServer, &IID_ISmtpAdminVirtualServer, &LIBID_SMTPADMLib>,
  19. public ISupportErrorInfo,
  20. public CComObjectRoot,
  21. public CComCoClass<CSmtpAdminVirtualServer,&CLSID_CSmtpAdminVirtualServer>
  22. {
  23. public:
  24. CSmtpAdminVirtualServer();
  25. virtual ~CSmtpAdminVirtualServer ();
  26. BEGIN_COM_MAP(CSmtpAdminVirtualServer)
  27. COM_INTERFACE_ENTRY(IDispatch)
  28. COM_INTERFACE_ENTRY(ISmtpAdminVirtualServer)
  29. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  30. END_COM_MAP()
  31. //DECLARE_NOT_AGGREGATABLE(CSmtpAdminVirtualServer)
  32. // Remove the comment from the line above if you don't want your object to
  33. // support aggregation. The default is to support it
  34. DECLARE_REGISTRY(CSmtpAdminVirtualServer, _T("Smtpadm.VirtualServer.1"), _T("Smtpadm.VirtualServer"), IDS_SMTPADMIN_VIRTUALSERVER_DESC, THREADFLAGS_BOTH)
  35. // ISupportsErrorInfo
  36. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  37. // ISmtpAdminVirtualServer
  38. public:
  39. //////////////////////////////////////////////////////////////////////
  40. // Properties:
  41. //////////////////////////////////////////////////////////////////////
  42. // Which service to configure:
  43. STDMETHODIMP get_Server ( BSTR * pstrServer );
  44. STDMETHODIMP put_Server ( BSTR strServer );
  45. STDMETHODIMP get_ServiceInstance ( long * plServiceInstance );
  46. STDMETHODIMP put_ServiceInstance ( long lServiceInstance );
  47. // other interfaces supported by virtual server
  48. STDMETHODIMP get_TcpAccess ( ITcpAccess ** ppTcpAccess );
  49. STDMETHODIMP get_Comment ( BSTR * pstrComment );
  50. STDMETHODIMP put_Comment ( BSTR strComment );
  51. STDMETHODIMP get_Bindings ( IServerBindings ** ppBindings );
  52. STDMETHODIMP get_BindingsDispatch ( IDispatch ** ppDispatch );
  53. STDMETHODIMP get_RoutingSource ( IRoutingSource ** ppRoutingSource );
  54. STDMETHODIMP get_RoutingSourceDispatch ( IDispatch ** ppRoutingSource );
  55. // Overridable server properties:
  56. STDMETHODIMP get_ServerBindings ( SAFEARRAY ** ppsastrServerBindings );
  57. STDMETHODIMP put_ServerBindings ( SAFEARRAY * pstrServerBindings );
  58. STDMETHODIMP get_ServerBindingsVariant ( SAFEARRAY ** ppsastrServerBindings );
  59. STDMETHODIMP put_ServerBindingsVariant ( SAFEARRAY * pstrServerBindings );
  60. STDMETHODIMP get_SecureBindings ( SAFEARRAY ** ppsastrSecureBindings );
  61. STDMETHODIMP put_SecureBindings ( SAFEARRAY * pstrSecureBindings );
  62. STDMETHODIMP get_SecureBindingsVariant ( SAFEARRAY ** ppsastrSecureBindings );
  63. STDMETHODIMP put_SecureBindingsVariant ( SAFEARRAY * pstrSecureBindings );
  64. STDMETHODIMP get_Port ( long * lPort );
  65. STDMETHODIMP put_Port ( long lPort );
  66. STDMETHODIMP get_SSLPort ( long * lSSLPort );
  67. STDMETHODIMP put_SSLPort ( long lSSLPort );
  68. STDMETHODIMP get_OutboundPort ( long * lOutboundPort );
  69. STDMETHODIMP put_OutboundPort ( long lOutboundPort );
  70. STDMETHODIMP get_HopCount ( long * lHopCount );
  71. STDMETHODIMP put_HopCount ( long lHopCount );
  72. STDMETHODIMP get_SmartHost ( BSTR * pstrSmartHost );
  73. STDMETHODIMP put_SmartHost ( BSTR pstrSmartHost );
  74. STDMETHODIMP get_EnableDNSLookup ( BOOL * pfEnableDNSLookup );
  75. STDMETHODIMP put_EnableDNSLookup ( BOOL fEnableDNSLookup );
  76. STDMETHODIMP get_PostmasterEmail ( BSTR * pstrPostmasterEmail );
  77. STDMETHODIMP put_PostmasterEmail ( BSTR strPostmasterEmail );
  78. STDMETHODIMP get_PostmasterName ( BSTR * pstrPostmasterName );
  79. STDMETHODIMP put_PostmasterName ( BSTR strPostmasterName );
  80. STDMETHODIMP get_DefaultDomain ( BSTR * pstrDefaultDomainName );
  81. STDMETHODIMP put_DefaultDomain ( BSTR strDefaultDomainName );
  82. STDMETHODIMP get_FQDN ( BSTR * pstrFQDN );
  83. STDMETHODIMP put_FQDN ( BSTR strFQDN );
  84. STDMETHODIMP get_DropDir ( BSTR * pstrDropDir );
  85. STDMETHODIMP put_DropDir ( BSTR strDropDir );
  86. STDMETHODIMP get_BadMailDir ( BSTR * pstrBadMailDir );
  87. STDMETHODIMP put_BadMailDir ( BSTR strBadMailDir );
  88. STDMETHODIMP get_PickupDir ( BSTR * pstrPickupDir );
  89. STDMETHODIMP put_PickupDir ( BSTR strPickupDir );
  90. STDMETHODIMP get_QueueDir ( BSTR * pstrQueueDir );
  91. STDMETHODIMP put_QueueDir ( BSTR strQueueDir );
  92. STDMETHODIMP get_MaxInConnection ( long * lMaxInConnection );
  93. STDMETHODIMP put_MaxInConnection ( long lMaxInConnection );
  94. STDMETHODIMP get_MaxOutConnection( long * lMaxOutConnection );
  95. STDMETHODIMP put_MaxOutConnection( long lMaxOutConnection );
  96. STDMETHODIMP get_InConnectionTimeout ( long * lInConnectionTimeout );
  97. STDMETHODIMP put_InConnectionTimeout ( long lInConnectionTimeout );
  98. STDMETHODIMP get_OutConnectionTimeout( long * lOutConnectionTimeout );
  99. STDMETHODIMP put_OutConnectionTimeout( long lOutConnectionTimeout );
  100. STDMETHODIMP get_MaxMessageSize ( long * lMaxMessageSize );
  101. STDMETHODIMP put_MaxMessageSize ( long lMaxMessageSize );
  102. STDMETHODIMP get_MaxSessionSize ( long * lMaxSessionSize );
  103. STDMETHODIMP put_MaxSessionSize ( long lMaxSessionSize );
  104. STDMETHODIMP get_MaxMessageRecipients ( long * lMaxMessageRecipients );
  105. STDMETHODIMP put_MaxMessageRecipients ( long lMaxMessageRecipients );
  106. STDMETHODIMP get_LocalRetries ( long * lLocalRetries );
  107. STDMETHODIMP put_LocalRetries ( long lLocalRetries );
  108. STDMETHODIMP get_LocalRetryTime ( long * lLocalRetryTime );
  109. STDMETHODIMP put_LocalRetryTime ( long lLocalRetryTime );
  110. STDMETHODIMP get_RemoteRetries ( long * lRemoteRetries );
  111. STDMETHODIMP put_RemoteRetries ( long lRemoteRetries );
  112. STDMETHODIMP get_RemoteRetryTime ( long * lRemoteRetryTime );
  113. STDMETHODIMP put_RemoteRetryTime ( long lRemoteRetryTime );
  114. STDMETHODIMP get_ETRNDays ( long * lETRNDays );
  115. STDMETHODIMP put_ETRNDays ( long lETRNDays );
  116. STDMETHODIMP get_SendDNRToPostmaster ( BOOL * pfSendDNRToPostmaster );
  117. STDMETHODIMP put_SendDNRToPostmaster ( BOOL fSendDNRToPostmaster );
  118. STDMETHODIMP get_SendBadmailToPostmaster ( BOOL * pfSendBadmailToPostmaster);
  119. STDMETHODIMP put_SendBadmailToPostmaster ( BOOL fSendBadmailToPostmaster );
  120. STDMETHODIMP get_RoutingDLL ( BSTR * pstrRoutingDLL );
  121. STDMETHODIMP put_RoutingDLL ( BSTR strRoutingDLL );
  122. STDMETHODIMP get_RoutingSources ( SAFEARRAY ** ppsastrRoutingSources );
  123. STDMETHODIMP put_RoutingSources ( SAFEARRAY * pstrRoutingSources );
  124. STDMETHODIMP get_RoutingSourcesVariant ( SAFEARRAY ** ppsavarRoutingSources );
  125. STDMETHODIMP put_RoutingSourcesVariant ( SAFEARRAY * psavarRoutingSources );
  126. STDMETHODIMP get_LocalDomains ( SAFEARRAY ** ppsastrLocalDomains );
  127. STDMETHODIMP put_LocalDomains ( SAFEARRAY * pstrLocalDomains );
  128. STDMETHODIMP get_DomainRouting ( SAFEARRAY ** ppsastrDomainRouting );
  129. STDMETHODIMP put_DomainRouting ( SAFEARRAY * pstrDomainRouting );
  130. STDMETHODIMP get_DomainRoutingVariant ( SAFEARRAY ** ppsastrDomainRouting );
  131. STDMETHODIMP put_DomainRoutingVariant ( SAFEARRAY * pstrDomainRouting );
  132. STDMETHODIMP get_MasqueradeDomain ( BSTR * pstrMasqueradeDomain );
  133. STDMETHODIMP put_MasqueradeDomain ( BSTR strMasqueradeDomain );
  134. STDMETHODIMP get_SendNdrTo ( BSTR * pstrAddr );
  135. STDMETHODIMP put_SendNdrTo ( BSTR strAddr );
  136. STDMETHODIMP get_SendBadTo ( BSTR * pstrAddr );
  137. STDMETHODIMP put_SendBadTo ( BSTR strAddr );
  138. STDMETHODIMP get_RemoteSecurePort ( long * plRemoteSecurePort );
  139. STDMETHODIMP put_RemoteSecurePort ( long lRemoteSecurePort );
  140. STDMETHODIMP get_ShouldDeliver ( BOOL * pfShouldDeliver );
  141. STDMETHODIMP put_ShouldDeliver ( BOOL fShouldDeliver );
  142. STDMETHODIMP get_AlwaysUseSsl ( BOOL * pfAlwaysUseSsl );
  143. STDMETHODIMP put_AlwaysUseSsl ( BOOL fAlwaysUseSsl );
  144. STDMETHODIMP get_LimitRemoteConnections ( BOOL * pfLimitRemoteConnections );
  145. STDMETHODIMP put_LimitRemoteConnections ( BOOL fLimitRemoteConnections );
  146. STDMETHODIMP get_MaxOutConnPerDomain ( long * plMaxOutConnPerDomain );
  147. STDMETHODIMP put_MaxOutConnPerDomain ( long lMaxOutConnPerDomain );
  148. STDMETHODIMP get_AllowVerify ( BOOL * pfAllowVerify );
  149. STDMETHODIMP put_AllowVerify ( BOOL fAllowVerify );
  150. STDMETHODIMP get_AllowExpand ( BOOL * pfAllowExpand );
  151. STDMETHODIMP put_AllowExpand ( BOOL fAllowExpand );
  152. STDMETHODIMP get_SmartHostType ( long * plSmartHostType );
  153. STDMETHODIMP put_SmartHostType ( long lSmartHostType );
  154. STDMETHODIMP get_BatchMessages ( BOOL * pfBatchMessages );
  155. STDMETHODIMP put_BatchMessages ( BOOL fBatchMessages );
  156. STDMETHODIMP get_BatchMessageLimit ( long * plBatchMessageLimit );
  157. STDMETHODIMP put_BatchMessageLimit ( long lBatchMessageLimit );
  158. STDMETHODIMP get_DoMasquerade ( BOOL * pfDoMasquerade );
  159. STDMETHODIMP put_DoMasquerade ( BOOL fDoMasquerade );
  160. STDMETHODIMP get_Administrators ( SAFEARRAY ** ppsastrAdmins );
  161. STDMETHODIMP put_Administrators ( SAFEARRAY * psastrAdmins );
  162. STDMETHODIMP get_AdministratorsVariant ( SAFEARRAY ** ppsastrAdmins );
  163. STDMETHODIMP put_AdministratorsVariant ( SAFEARRAY * psastrAdmins );
  164. STDMETHODIMP get_AuthenticationPackages ( BSTR * pstrAuthenticationPackages );
  165. STDMETHODIMP put_AuthenticationPackages ( BSTR strAuthenticationPackages );
  166. STDMETHODIMP get_ClearTextAuthPackage ( BSTR * pstrClearTextAuthPackage );
  167. STDMETHODIMP put_ClearTextAuthPackage ( BSTR strClearTextAuthPackage );
  168. STDMETHODIMP get_AuthenticationMethod (long *plAuthMethod);
  169. STDMETHODIMP put_AuthenticationMethod (long lAuthMethod);
  170. STDMETHODIMP get_DefaultLogonDomain (BSTR *pstrLogonDomain);
  171. STDMETHODIMP put_DefaultLogonDomain (BSTR strLogonDomain);
  172. STDMETHODIMP get_RouteAction (long *plRouteAction);
  173. STDMETHODIMP put_RouteAction (long lRouteAction);
  174. STDMETHODIMP get_RouteUserName (BSTR *pstrRouteUserName);
  175. STDMETHODIMP put_RouteUserName (BSTR strRouteUserName);
  176. STDMETHODIMP get_RoutePassword (BSTR *pstrRoutePassword);
  177. STDMETHODIMP put_RoutePassword (BSTR strRoutePassword);
  178. STDMETHODIMP get_LogFileDirectory ( BSTR * pstrLogFileDirectory );
  179. STDMETHODIMP put_LogFileDirectory ( BSTR strLogFileDirectory );
  180. STDMETHODIMP get_LogFilePeriod ( long * lLogFilePeriod );
  181. STDMETHODIMP put_LogFilePeriod ( long lLogFilePeriod );
  182. STDMETHODIMP get_LogFileTruncateSize ( long * lLogFileTruncateSize );
  183. STDMETHODIMP put_LogFileTruncateSize ( long lLogFileTruncateSize );
  184. STDMETHODIMP get_LogMethod ( long * lLogMethod );
  185. STDMETHODIMP put_LogMethod ( long lLogMethod );
  186. STDMETHODIMP get_LogType ( long * lLogType );
  187. STDMETHODIMP put_LogType ( long lLogType );
  188. /*
  189. STDMETHODIMP get_DisplayName ( BSTR * pstrDisplayName );
  190. STDMETHODIMP put_DisplayName ( BSTR strDisplayName );
  191. */
  192. //
  193. // Service State Properties:
  194. //
  195. STDMETHODIMP get_AutoStart ( BOOL * pfAutoStart );
  196. STDMETHODIMP put_AutoStart ( BOOL fAutoStart );
  197. STDMETHODIMP get_ServerState ( DWORD * pdwServerState );
  198. STDMETHODIMP get_Win32ErrorCode ( long * plWin32ErrorCode );
  199. //////////////////////////////////////////////////////////////////////
  200. // Methods:
  201. //////////////////////////////////////////////////////////////////////
  202. STDMETHODIMP Get ( );
  203. STDMETHODIMP Set ( BOOL fFailIfChanged );
  204. STDMETHODIMP BackupRoutingTable( BSTR strPath );
  205. STDMETHODIMP Start ( );
  206. STDMETHODIMP Pause ( );
  207. STDMETHODIMP Continue ( );
  208. STDMETHODIMP Stop ( );
  209. //////////////////////////////////////////////////////////////////////
  210. // Data:
  211. //////////////////////////////////////////////////////////////////////
  212. private:
  213. // Properties:
  214. CComBSTR m_strServer;
  215. DWORD m_dwServiceInstance;
  216. long m_lPort;
  217. CMultiSz m_mszServerBindings; // MultiString
  218. CMultiSz m_mszSecureBindings; // MultiString
  219. long m_lSSLPort;
  220. long m_lOutboundPort;
  221. long m_lRemoteSecurePort;
  222. CComBSTR m_strSmartHost;
  223. BOOL m_fEnableDNSLookup;
  224. CComBSTR m_strPostmasterEmail;
  225. CComBSTR m_strPostmasterName;
  226. CComBSTR m_strFQDN;
  227. CComBSTR m_strDefaultDomain;
  228. CComBSTR m_strDropDir;
  229. CComBSTR m_strBadMailDir;
  230. CComBSTR m_strPickupDir;
  231. CComBSTR m_strQueueDir;
  232. long m_lHopCount;
  233. long m_lMaxInConnection;
  234. long m_lMaxOutConnection;
  235. long m_lInConnectionTimeout;
  236. long m_lOutConnectionTimeout;
  237. long m_lMaxMessageSize;
  238. long m_lMaxSessionSize;
  239. long m_lMaxMessageRecipients;
  240. long m_lLocalRetries;
  241. long m_lLocalRetryTime;
  242. long m_lRemoteRetries;
  243. long m_lRemoteRetryTime;
  244. long m_lETRNDays;
  245. BOOL m_fSendDNRToPostmaster;
  246. BOOL m_fSendBadmailToPostmaster;
  247. CComBSTR m_strRoutingDLL;
  248. CMultiSz m_mszRoutingSources; // MultiString
  249. CMultiSz m_mszLocalDomains; // MultiString
  250. CMultiSz m_mszDomainRouting; // MultiString
  251. BOOL m_fDoMasquerade;
  252. CComBSTR m_strMasqueradeDomain;
  253. CComBSTR m_strNdrAddr;
  254. CComBSTR m_strBadAddr;
  255. BOOL m_fShouldDeliver;
  256. BOOL m_fAlwaysUseSsl;
  257. BOOL m_fLimitRemoteConnections;
  258. long m_lMaxOutConnPerDomain;
  259. BOOL m_fAllowVerify;
  260. BOOL m_fAllowExpand;
  261. long m_lSmartHostType;
  262. BOOL m_fBtachMsgs;
  263. long m_lBatchMsgLimit;
  264. SAFEARRAY * m_psaAdmins;
  265. long m_lAuthMethod;
  266. CComBSTR m_strAuthPackages;
  267. CComBSTR m_strClearTextAuthPackage;
  268. CComBSTR m_strDefaultLogonDomain;
  269. // outbound security
  270. long m_lRouteAction;
  271. CComBSTR m_strRouteUserName;
  272. CComBSTR m_strRoutePassword;
  273. CComBSTR m_strLogFileDirectory;
  274. long m_lLogFilePeriod;
  275. long m_lLogFileTruncateSize;
  276. long m_lLogMethod;
  277. long m_lLogType;
  278. BOOL m_fAutoStart;
  279. //service specific
  280. CComBSTR m_strComment;
  281. // Service State:
  282. DWORD m_dwServerState;
  283. DWORD m_dwWin32ErrorCode;
  284. // Unused so far:
  285. CComBSTR m_strDisplayName;
  286. // Tcp restrictions:
  287. CComPtr<ITcpAccess> m_pIpAccess;
  288. CTcpAccess * m_pPrivateIpAccess;
  289. // Bindings:
  290. CComPtr<IServerBindings> m_pBindings;
  291. CServerBindings * m_pPrivateBindings;
  292. CComObject<CRoutingSource> m_RoutingSource;
  293. // Status:
  294. BOOL m_fGotProperties;
  295. DWORD m_bvChangedFields;
  296. FILETIME m_ftLastChanged;
  297. // Metabase:
  298. CMetabaseFactory m_mbFactory;
  299. HRESULT GetPropertiesFromMetabase ( IMSAdminBase * pMetabase );
  300. HRESULT SendPropertiesToMetabase ( BOOL fFailIfChanged, IMSAdminBase * pMetabase );
  301. // State:
  302. HRESULT ControlService (
  303. IMSAdminBase * pMetabase,
  304. DWORD ControlCode,
  305. DWORD dwDesiredState,
  306. DWORD dwPendingState
  307. );
  308. HRESULT WriteStateCommand ( IMSAdminBase * pMetabase, DWORD dwCommand );
  309. HRESULT CheckServiceState ( IMSAdminBase * pMetabase, DWORD * pdwState );
  310. //NNTP_SERVER_STATE TranslateServerState ( DWORD dwState );
  311. // Validation:
  312. BOOL ValidateStrings ( ) const;
  313. BOOL ValidateProperties ( ) const;
  314. void CorrectProperties ( );
  315. };