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.

422 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. rpcex.cxx
  5. Abstract:
  6. This module defines K2 rpc support.
  7. Author:
  8. Johnson Apacible (JohnsonA) June-19-1996
  9. --*/
  10. #define INCL_INETSRV_INCS
  11. #include "smtpinc.h"
  12. #if 0
  13. #include <timer.h>
  14. #include <time.h>
  15. #endif
  16. #include "iiscnfg.h"
  17. #include <mdmsg.h>
  18. #include <commsg.h>
  19. #include <imd.h>
  20. #include <mb.hxx>
  21. BOOL
  22. IsSmtpEncryptionPermitted(
  23. VOID
  24. )
  25. /*++
  26. Routine Description:
  27. This routine checks whether encryption is getting the system default
  28. LCID and checking whether the country code is CTRY_FRANCE.
  29. Arguments:
  30. none
  31. Return Value:
  32. TRUE - encryption is permitted
  33. FALSE - encryption is not permitted
  34. --*/
  35. {
  36. LCID DefaultLcid;
  37. WCHAR CountryCode[10];
  38. ULONG CountryValue;
  39. DefaultLcid = GetSystemDefaultLCID();
  40. //
  41. // Check if the default language is Standard French
  42. //
  43. if (LANGIDFROMLCID(DefaultLcid) == 0x40c) {
  44. return(FALSE);
  45. }
  46. //
  47. // Check if the users's country is set to FRANCE
  48. //
  49. if (GetLocaleInfoW(DefaultLcid,LOCALE_ICOUNTRY,CountryCode,10) == 0) {
  50. return(FALSE);
  51. }
  52. CountryValue = (ULONG) wcstol(CountryCode,NULL,10);
  53. if (CountryValue == CTRY_FRANCE) {
  54. return(FALSE);
  55. }
  56. return(TRUE);
  57. } // IsEncryptionPermitted
  58. DWORD
  59. SMTP_SERVER_INSTANCE::QueryEncCaps(
  60. VOID
  61. )
  62. /*++
  63. Description
  64. Returns encryption capability
  65. Arguments:
  66. None
  67. Return:
  68. Encryption capability
  69. --*/
  70. {
  71. //
  72. // Get the encryption capability bits. SecurePort may be zero because
  73. // no keys are installed or the locale does not allow encryption
  74. //
  75. return 0;
  76. } // SMTP_SERVER_INSTANCE::QueryEncCaps
  77. BOOL
  78. SMTP_SERVER_INSTANCE::SetServiceConfig(
  79. IN PCHAR pBuffer
  80. )
  81. /*++
  82. Description
  83. Sets the common service admin information for the servers specified
  84. in dwServerMask.
  85. Arguments:
  86. pConfig - Admin information to set
  87. Note:
  88. --*/
  89. {
  90. return TRUE;
  91. } // SMTP_SERVER_INSTANCE::SetServiceConfig
  92. BOOL
  93. SMTP_SERVER_INSTANCE::GetServiceConfig(
  94. IN PCHAR pBuffer,
  95. IN DWORD dwLevel
  96. )
  97. /*++
  98. Description
  99. Retrieves the admin information
  100. Arguments:
  101. pBuffer - Buffer to fill up.
  102. dwLevel - info level of information to return.
  103. Note:
  104. --*/
  105. {
  106. LPSMTP_CONFIG_INFO pConfig = (LPSMTP_CONFIG_INFO)pBuffer;
  107. DWORD err = NO_ERROR;
  108. MB MetaInfo( (IMDCOM*) g_pInetSvc->QueryMDObject() );
  109. ZeroMemory( pConfig, sizeof( SMTP_CONFIG_INFO ) );
  110. // We want to open a read handle to the server instance
  111. // name, and then we'll read the indivdual info out next.
  112. //
  113. if ( !MetaInfo.Open( QueryMDVRPath() ))
  114. {
  115. return FALSE;
  116. }
  117. LockThisForRead();
  118. //
  119. // Get always retrieves all of the parameters
  120. //
  121. pConfig->FieldControl = FC_SMTP_INFO_ALL;
  122. //
  123. // Set the encryption capability bits. SecurePort may be zero
  124. // because no keys are installed or the locale does not allow
  125. // encryption
  126. //
  127. UnlockThis();
  128. SetLastError(err);
  129. return(err==NO_ERROR);
  130. } // W3_SERVER_INSTANCE::GetServiceConfig
  131. BOOL
  132. SMTP_SERVER_INSTANCE::EnumerateUsers(
  133. OUT PCHAR * pBuffer,
  134. OUT PDWORD nRead
  135. )
  136. /*++
  137. Description
  138. Enumerates the connected users.
  139. Arguments:
  140. pBuffer - Buffer to fill up.
  141. --*/
  142. {
  143. BOOL fRet = TRUE;
  144. #if 0
  145. //
  146. // Lock the user database.
  147. //
  148. LockUserDatabase();
  149. //
  150. // Determine the necessary buffer size.
  151. //
  152. pBuffer->EntriesRead = 0;
  153. pBuffer->Buffer = NULL;
  154. cbBuffer = 0;
  155. err = NERR_Success;
  156. EnumerateUsers( pBuffer, &cbBuffer );
  157. if( cbBuffer > 0 )
  158. {
  159. //
  160. // Allocate the buffer. Note that we *must*
  161. // use midl_user_allocate/midl_user_free.
  162. //
  163. pBuffer->Buffer = (W3_USER_INFO *) MIDL_user_allocate( (unsigned int)cbBuffer );
  164. if( pBuffer->Buffer == NULL )
  165. {
  166. err = ERROR_NOT_ENOUGH_MEMORY;
  167. }
  168. else
  169. {
  170. //
  171. // Since we've got the user database locked, there
  172. // *should* be enough room in the buffer for the
  173. // user data. If there isn't, we've messed up
  174. // somewhere.
  175. //
  176. TCP_REQUIRE( ::EnumerateUsers( pBuffer, &cbBuffer ) );
  177. }
  178. }
  179. //
  180. // Unlock the user database before returning.
  181. UnlockUserDatabase();
  182. #endif //0
  183. return fRet;
  184. } // EnumerateUsers
  185. BOOL
  186. SMTP_SERVER_INSTANCE::DisconnectUser(
  187. IN DWORD dwIdUser
  188. )
  189. /*++
  190. Description
  191. Disconnect the user
  192. Arguments:
  193. dwIdUser - Identifies the user to disconnect. If 0,
  194. then disconnect ALL users.
  195. --*/
  196. {
  197. BOOL fRet = TRUE;
  198. //
  199. // Do it.
  200. //
  201. if( dwIdUser == 0 )
  202. {
  203. DisconnectAllConnections();
  204. }
  205. else
  206. {
  207. #if 0
  208. if( !CLIENT_CONN::DisconnectUser( idUser ) )
  209. {
  210. err = NERR_UserNotFound;
  211. }
  212. #endif
  213. }
  214. return fRet;
  215. } // DisconnectUser
  216. BOOL
  217. SMTP_SERVER_INSTANCE::GetStatistics(
  218. IN DWORD dwLevel,
  219. OUT PCHAR* pBuffer
  220. )
  221. /*++
  222. Description
  223. Disconnect Queries the server statistics
  224. Arguments:
  225. dwLevel - Info level. Currently only level 0 is
  226. supported.
  227. pBuffer - Will receive a pointer to the statistics
  228. structure.
  229. --*/
  230. {
  231. APIERR err = NO_ERROR;
  232. //
  233. // Return the proper statistics based on the infolevel.
  234. //
  235. switch( dwLevel )
  236. {
  237. case 0 :
  238. {
  239. LPSMTP_STATISTICS_0 pstats1;
  240. pstats1 = (SMTP_STATISTICS_0 *) MIDL_user_allocate( sizeof(SMTP_STATISTICS_0) );
  241. if( pstats1 == NULL )
  242. {
  243. err = ERROR_NOT_ENOUGH_MEMORY;
  244. }
  245. else
  246. {
  247. QueryStatsObj()->CopyToStatsBuffer( pstats1 );
  248. //pstats1->TimeOfLastClear = GetCurrentTimeInSeconds() -
  249. // pstats1->TimeOfLastClear;
  250. //
  251. // Copy Global statistics counter values
  252. //
  253. //pstats1->CurrentConnections =
  254. // g_pSmtpStats->QueryStatsObj()->m_cCurrentConnections;
  255. //pstats1->MaxConnections =
  256. // g_pSmtpStats->QueryStatsObj()->m_cMaxCurrentConnections;
  257. //pstats1->ConnectionAttempts =
  258. // g_pSmtpStats->QueryStatsObj()->ConnectionAttempts;
  259. *pBuffer = (PCHAR)pstats1;
  260. }
  261. }
  262. break;
  263. default :
  264. err = ERROR_INVALID_LEVEL;
  265. break;
  266. }
  267. SetLastError(err);
  268. return(err == NO_ERROR);
  269. } // QueryStatistics
  270. BOOL
  271. SMTP_SERVER_INSTANCE::ClearStatistics(
  272. VOID
  273. )
  274. /*++
  275. Description
  276. Clears the server statistics
  277. Arguments:
  278. None.
  279. --*/
  280. {
  281. QueryStatsObj()->ClearStatistics();
  282. return TRUE;
  283. } // ClearStatistics