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.

509 lines
10 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. #include "w3p.hxx"
  11. #include "w3svci_s.h"
  12. #include <timer.h>
  13. #include <time.h>
  14. #include <ole2.h>
  15. #include <imd.h>
  16. #include <mb.hxx>
  17. #include "httpxpc.h"
  18. BOOL
  19. IsEncryptionPermitted(
  20. VOID
  21. )
  22. /*++
  23. Routine Description:
  24. This routine checks whether encryption is getting the system default
  25. LCID and checking whether the country code is CTRY_FRANCE.
  26. Arguments:
  27. none
  28. Return Value:
  29. TRUE - encryption is permitted
  30. FALSE - encryption is not permitted
  31. --*/
  32. {
  33. LCID DefaultLcid;
  34. WCHAR CountryCode[10];
  35. ULONG CountryValue;
  36. DefaultLcid = GetSystemDefaultLCID();
  37. //
  38. // Check if the default language is Standard French
  39. //
  40. if (LANGIDFROMLCID(DefaultLcid) == 0x40c) {
  41. return(FALSE);
  42. }
  43. //
  44. // Check if the users's country is set to FRANCE
  45. //
  46. if (GetLocaleInfoW(DefaultLcid,LOCALE_ICOUNTRY,CountryCode,10) == 0) {
  47. return(FALSE);
  48. }
  49. CountryValue = (ULONG) wcstol(CountryCode,NULL,10);
  50. if (CountryValue == CTRY_FRANCE) {
  51. return(FALSE);
  52. }
  53. return(TRUE);
  54. } // IsEncryptionPermitted
  55. DWORD
  56. W3_SERVER_INSTANCE::QueryEncCaps(
  57. VOID
  58. )
  59. /*++
  60. Description
  61. Returns encryption capability
  62. Arguments:
  63. None
  64. Return:
  65. Encryption capability
  66. --*/
  67. {
  68. //
  69. // Get the encryption capability bits. SecurePort may be zero because
  70. // no keys are installed or the locale does not allow encryption
  71. //
  72. return !HasSecureBindings()
  73. ? (IsEncryptionPermitted()
  74. ? ENC_CAPS_NOT_INSTALLED
  75. : ENC_CAPS_DISABLED)
  76. // note : we do not currently support PCT
  77. : ENC_CAPS_SSL;
  78. } // W3_SERVER_INSTANCE::QueryEncCaps
  79. BOOL
  80. W3_SERVER_INSTANCE::SetServiceConfig(
  81. IN PCHAR pBuffer
  82. )
  83. /*++
  84. Description
  85. Sets the common service admin information for the servers specified
  86. in dwServerMask.
  87. Arguments:
  88. pConfig - Admin information to set
  89. Note:
  90. --*/
  91. {
  92. LPW3_CONFIG_INFO pConfig = (LPW3_CONFIG_INFO)pBuffer;
  93. if ( !WritePublicW3Params( pConfig ) ||
  94. !ReadPublicW3Params( pConfig->FieldControl ))
  95. {
  96. return FALSE;
  97. }
  98. return TRUE;
  99. } // W3_SERVER_INSTANCE::SetServiceConfig
  100. BOOL
  101. W3_SERVER_INSTANCE::GetServiceConfig(
  102. IN PCHAR pBuffer,
  103. IN DWORD dwLevel
  104. )
  105. /*++
  106. Description
  107. Retrieves the admin information
  108. Arguments:
  109. pBuffer - Buffer to fill up.
  110. dwLevel - info level of information to return.
  111. Note:
  112. --*/
  113. {
  114. LPW3_CONFIG_INFO pConfig = (LPW3_CONFIG_INFO)pBuffer;
  115. DWORD err = NO_ERROR;
  116. MB MetaInfo( (IMDCOM*) g_pInetSvc->QueryMDObject() );
  117. STR strDefaultFile;
  118. ZeroMemory( pConfig, sizeof( W3_CONFIG_INFO ) );
  119. // We want to open a read handle to the server instance
  120. // name, and then we'll read the indivdual info out next.
  121. //
  122. if ( !MetaInfo.Open( QueryMDVRPath() ))
  123. {
  124. return FALSE;
  125. }
  126. LockThisForRead();
  127. //
  128. // Get always retrieves all of the parameters
  129. //
  130. pConfig->FieldControl = FC_W3_ALL;
  131. if (!MetaInfo.GetDword("/", MD_DIRECTORY_BROWSING,
  132. IIS_MD_UT_FILE, &pConfig->dwDirBrowseControl))
  133. {
  134. err = GetLastError();
  135. if (err == MD_ERROR_DATA_NOT_FOUND)
  136. {
  137. pConfig->dwDirBrowseControl = DEFAULT_DIR_BROWSE_CONTROL;
  138. err = NO_ERROR;
  139. }
  140. else
  141. {
  142. goto done;
  143. }
  144. }
  145. if ( !MetaInfo.GetStr( "/",
  146. MD_DEFAULT_LOAD_FILE,
  147. IIS_MD_UT_FILE,
  148. &strDefaultFile,
  149. METADATA_INHERIT,
  150. "default.htm" ))
  151. {
  152. err = GetLastError();
  153. goto done;
  154. }
  155. pConfig->fCheckForWAISDB = FALSE;
  156. pConfig->fServerAsProxy = FALSE;
  157. pConfig->fSSIEnabled = FALSE;
  158. pConfig->csecGlobalExpire = 0;
  159. //
  160. // Set the encryption capability bits. SecurePort may be zero
  161. // because no keys are installed or the locale does not allow
  162. // encryption
  163. //
  164. pConfig->dwEncCaps |= QueryEncCaps();
  165. if ( !ConvertStringToRpc( &pConfig->lpszDefaultLoadFile,
  166. strDefaultFile.QueryStr() ) ||
  167. !ConvertStringToRpc( &pConfig->lpszDirectoryImage,
  168. "" ) ||
  169. !ConvertStringToRpc( &pConfig->lpszSSIExtension,
  170. "" ))
  171. {
  172. err = GetLastError();
  173. FreeRpcString( pConfig->lpszDefaultLoadFile );
  174. FreeRpcString( pConfig->lpszDirectoryImage );
  175. FreeRpcString( pConfig->lpszCatapultUser );
  176. FreeRpcString( pConfig->lpszSSIExtension );
  177. }
  178. done:
  179. UnlockThis();
  180. SetLastError(err);
  181. return(err==NO_ERROR);
  182. } // W3_SERVER_INSTANCE::GetServiceConfig
  183. BOOL
  184. W3_SERVER_INSTANCE::EnumerateUsers(
  185. OUT PCHAR * pBuffer,
  186. OUT PDWORD nRead
  187. )
  188. /*++
  189. Description
  190. Enumerates the connected users.
  191. Arguments:
  192. pBuffer - Buffer to fill up.
  193. --*/
  194. {
  195. BOOL fRet = TRUE;
  196. #if 0
  197. //
  198. // Lock the user database.
  199. //
  200. LockUserDatabase();
  201. //
  202. // Determine the necessary buffer size.
  203. //
  204. pBuffer->EntriesRead = 0;
  205. pBuffer->Buffer = NULL;
  206. cbBuffer = 0;
  207. err = NERR_Success;
  208. EnumerateUsers( pBuffer, &cbBuffer );
  209. if( cbBuffer > 0 )
  210. {
  211. //
  212. // Allocate the buffer. Note that we *must*
  213. // use midl_user_allocate/midl_user_free.
  214. //
  215. pBuffer->Buffer = (W3_USER_INFO *) MIDL_user_allocate( (unsigned int)cbBuffer );
  216. if( pBuffer->Buffer == NULL )
  217. {
  218. err = ERROR_NOT_ENOUGH_MEMORY;
  219. }
  220. else
  221. {
  222. //
  223. // Since we've got the user database locked, there
  224. // *should* be enough room in the buffer for the
  225. // user data. If there isn't, we've messed up
  226. // somewhere.
  227. //
  228. TCP_REQUIRE( ::EnumerateUsers( pBuffer, &cbBuffer ) );
  229. }
  230. }
  231. //
  232. // Unlock the user database before returning.
  233. UnlockUserDatabase();
  234. #endif //0
  235. return fRet;
  236. } // EnumerateUsers
  237. BOOL
  238. W3_SERVER_INSTANCE::DisconnectUser(
  239. IN DWORD dwIdUser
  240. )
  241. /*++
  242. Description
  243. Disconnect the user
  244. Arguments:
  245. dwIdUser - Identifies the user to disconnect. If 0,
  246. then disconnect ALL users.
  247. --*/
  248. {
  249. BOOL fRet = TRUE;
  250. //
  251. // Do it.
  252. //
  253. if( dwIdUser == 0 )
  254. {
  255. CLIENT_CONN::DisconnectAllUsers();
  256. }
  257. else
  258. {
  259. #if 0
  260. if( !CLIENT_CONN::DisconnectUser( idUser ) )
  261. {
  262. err = NERR_UserNotFound;
  263. }
  264. #endif
  265. }
  266. return fRet;
  267. } // DisconnectUser
  268. BOOL
  269. W3_SERVER_INSTANCE::GetStatistics(
  270. IN DWORD dwLevel,
  271. OUT PCHAR* pBuffer
  272. )
  273. /*++
  274. Description
  275. Disconnect Queries the server statistics
  276. Arguments:
  277. dwLevel - Info level. Currently only level 0 is
  278. supported.
  279. pBuffer - Will receive a pointer to the statistics
  280. structure.
  281. --*/
  282. {
  283. APIERR err = NO_ERROR;
  284. //
  285. // Return the proper statistics based on the infolevel.
  286. //
  287. switch( dwLevel )
  288. {
  289. case 0 :
  290. {
  291. LPW3_STATISTICS_1 pstats1;
  292. pstats1 = (W3_STATISTICS_1 *) MIDL_user_allocate( sizeof(W3_STATISTICS_1) );
  293. if( pstats1 == NULL )
  294. {
  295. err = ERROR_NOT_ENOUGH_MEMORY;
  296. }
  297. else
  298. {
  299. ATQ_STATISTICS atqStat;
  300. ZeroMemory( pstats1, sizeof( W3_STATISTICS_1 ) );
  301. QueryStatsObj()->CopyToStatsBuffer( pstats1 );
  302. //
  303. // Merge in HTTPEXT statistics
  304. //
  305. W3MergeDavPerformanceData( QueryInstanceId(), pstats1 );
  306. //
  307. // Get instance's bandwidth throttling statistics
  308. //
  309. if ( QueryBandwidthInfo() )
  310. {
  311. if ( AtqBandwidthGetInfo( QueryBandwidthInfo(),
  312. ATQ_BW_STATISTICS,
  313. (ULONG_PTR *) &atqStat ) )
  314. {
  315. pstats1->TotalBlockedRequests = atqStat.cBlockedRequests;
  316. pstats1->TotalRejectedRequests = atqStat.cRejectedRequests;
  317. pstats1->TotalAllowedRequests = atqStat.cAllowedRequests;
  318. pstats1->CurrentBlockedRequests = atqStat.cCurrentBlockedRequests;
  319. pstats1->MeasuredBw = atqStat.MeasuredBandwidth;
  320. }
  321. }
  322. pstats1->TimeOfLastClear = GetCurrentTimeInSeconds() -
  323. pstats1->TimeOfLastClear;
  324. //
  325. // Copy Global statistics counter values
  326. //
  327. pstats1->CurrentConnections =
  328. g_pW3Stats->QueryStatsObj()->CurrentConnections;
  329. pstats1->MaxConnections =
  330. g_pW3Stats->QueryStatsObj()->MaxConnections;
  331. pstats1->ConnectionAttempts =
  332. g_pW3Stats->QueryStatsObj()->ConnectionAttempts;
  333. *pBuffer = (PCHAR)pstats1;
  334. }
  335. }
  336. break;
  337. default :
  338. err = ERROR_INVALID_LEVEL;
  339. break;
  340. }
  341. SetLastError(err);
  342. return(err == NO_ERROR);
  343. } // QueryStatistics
  344. BOOL
  345. W3_SERVER_INSTANCE::ClearStatistics(
  346. VOID
  347. )
  348. /*++
  349. Description
  350. Clears the server statistics
  351. Arguments:
  352. None.
  353. --*/
  354. {
  355. QueryStatsObj()->ClearStatistics();
  356. return TRUE;
  357. } // ClearStatistics