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.

596 lines
12 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. rpccom.cxx
  5. Abstract:
  6. This module contains the server side service RPC admin APIs for K2
  7. Author:
  8. Johnson Apacible (johnsona) 06-03-96
  9. --*/
  10. //
  11. // Include Headers
  12. //
  13. #include <tcpdllp.hxx>
  14. #include <tsunami.hxx>
  15. extern "C" {
  16. #include <info_srv.h>
  17. };
  18. #include <atq.h>
  19. #include "inetreg.h"
  20. #include <iisver.h>
  21. // forward definition
  22. NET_API_STATUS
  23. NET_API_FUNCTION
  24. InitW3PerfCounters(
  25. OUT LPDWORD lpcbTotalRequired
  26. );
  27. NET_API_STATUS
  28. NET_API_FUNCTION
  29. CollectW3PerfCounters( LPWSTR lpValueName,
  30. LPBYTE * lppData,
  31. LPDWORD lpcbTotalBytes,
  32. LPDWORD lpNumObjectTypes
  33. );
  34. NET_API_STATUS
  35. NET_API_FUNCTION
  36. GetStatistics(
  37. IN DWORD dwLevel,
  38. IN DWORD dwServiceId,
  39. IN DWORD dwInstance,
  40. OUT PCHAR * pBuffer
  41. )
  42. /*++
  43. Description
  44. Common get statistics routine
  45. Arguments:
  46. dwLevel - level of the statistics to get
  47. dwServiceId - ID of the service to get stats from
  48. dwInstance - instance whose stats we are to get
  49. InfoStruct - Will contain the returned buffer
  50. Note:
  51. --*/
  52. {
  53. DWORD err = NO_ERROR;
  54. PCHAR buffer;
  55. PIIS_SERVICE pInetSvc;
  56. IF_DEBUG( DLL_RPC) {
  57. DBGPRINTF( ( DBG_CONTEXT,
  58. " Entering GetStatistics (L%d)\n", dwLevel));
  59. }
  60. //
  61. // Do we have permissions?
  62. //
  63. if ( (err = TsApiAccessCheck( TCP_QUERY_STATISTICS )) != NO_ERROR) {
  64. IF_DEBUG( DLL_RPC) {
  65. DBGPRINTF( ( DBG_CONTEXT,
  66. " TsApiAccessCheck() Failed. Error = %u\n", err));
  67. }
  68. return(err);
  69. }
  70. pInetSvc = IIS_SERVICE::FindFromServiceInfoList( dwServiceId );
  71. if ( pInetSvc == NULL ) {
  72. return ERROR_SERVICE_NOT_ACTIVE;
  73. }
  74. //
  75. // Get the params
  76. //
  77. if (!pInetSvc->GetInstanceStatistics(
  78. dwInstance,
  79. dwLevel,
  80. pBuffer
  81. ) ) {
  82. err = GetLastError();
  83. IF_DEBUG( DLL_RPC) {
  84. DBGPRINTF( ( DBG_CONTEXT,
  85. "GetInstanceStats failed. Error = %u\n",
  86. err));
  87. }
  88. }
  89. //
  90. // This was referenced in Find
  91. //
  92. pInetSvc->Dereference( );
  93. return err;
  94. } // GetStatistics
  95. NET_API_STATUS
  96. NET_API_FUNCTION
  97. ClearStatistics(
  98. IN DWORD dwServiceId,
  99. IN DWORD dwInstance
  100. )
  101. /*++
  102. Description
  103. Common get statistics routine
  104. Arguments:
  105. pszServer - unused
  106. dwServerMask - Bitfield of servers to set the information for
  107. pConfig - Admin information to set
  108. Note:
  109. --*/
  110. {
  111. DWORD err = NO_ERROR;
  112. PCHAR buffer;
  113. PIIS_SERVICE pInetSvc;
  114. IF_DEBUG( DLL_RPC) {
  115. DBGPRINTF( ( DBG_CONTEXT,
  116. " Entering ClearStatistics (Instance %d)\n", dwInstance));
  117. }
  118. //
  119. // Do we have permissions?
  120. //
  121. if ( (err = TsApiAccessCheck( TCP_CLEAR_STATISTICS )) != NO_ERROR) {
  122. IF_DEBUG( DLL_RPC) {
  123. DBGPRINTF( ( DBG_CONTEXT,
  124. " TsApiAccessCheck() Failed. Error = %u\n", err));
  125. }
  126. return(err);
  127. }
  128. pInetSvc = IIS_SERVICE::FindFromServiceInfoList( dwServiceId );
  129. if ( pInetSvc == NULL ) {
  130. return ERROR_SERVICE_NOT_ACTIVE;
  131. }
  132. //
  133. // Get the params
  134. //
  135. if (!pInetSvc->ClearInstanceStatistics(dwInstance) ) {
  136. err = GetLastError();
  137. IF_DEBUG( DLL_RPC) {
  138. DBGPRINTF( ( DBG_CONTEXT,
  139. "GetInstanceStats failed. Error = %u\n",
  140. err));
  141. }
  142. }
  143. //
  144. // This was referenced in Find
  145. //
  146. pInetSvc->Dereference( );
  147. return err;
  148. } // ClearStatistics
  149. NET_API_STATUS
  150. NET_API_FUNCTION
  151. R_InitW3CounterStructure(
  152. IN LPWSTR pszServer OPTIONAL,
  153. OUT LPDWORD lpcbTotalRequired
  154. )
  155. /*++
  156. Description
  157. Initialize W3 object and counter indexes
  158. Arguments:
  159. pszServer - unused
  160. lpcbTotalRequired - size of memory needed to retrieve w3 performance data
  161. Note:
  162. --*/
  163. {
  164. return ERROR_NOT_SUPPORTED;
  165. } // R_InitW3CounterStructure
  166. NET_API_STATUS
  167. NET_API_FUNCTION
  168. R_CollectW3PerfData(
  169. IN LPWSTR pszServer OPTIONAL,
  170. IN LPWSTR lpValueName,
  171. OUT LPBYTE lppData,
  172. IN OUT LPDWORD lpcbTotalBytes,
  173. OUT LPDWORD lpNumObjectTypes
  174. )
  175. /*++
  176. Description
  177. Collect W3 perfomance data
  178. Arguments:
  179. pszServer - unused
  180. lpValueName - counter object name to be retrieved
  181. lppData - will hold the returned W3 performance data
  182. lpcbTotalBytes - total bytes of W3 performance data returned
  183. lpNumobjectTypes - number of object types returned
  184. Note:
  185. --*/
  186. {
  187. return ERROR_NOT_SUPPORTED;
  188. }
  189. NET_API_STATUS
  190. NET_API_FUNCTION
  191. R_W3QueryStatistics2(
  192. IN LPWSTR pszServer OPTIONAL,
  193. IN DWORD dwLevel,
  194. IN DWORD dwInstance,
  195. IN DWORD dwReserved,
  196. IN LPW3_STATISTICS_STRUCT InfoStruct
  197. )
  198. /*++
  199. Description
  200. Gets the W3 specific statistics
  201. Arguments:
  202. pszServer - unused
  203. dwLevel - level of the statistics to get
  204. dwInstance - instance whose stats we are to get
  205. dwReserved - MBZ
  206. InfoStruct - Will contain the returned buffer
  207. Note:
  208. --*/
  209. {
  210. DWORD err;
  211. PCHAR buffer;
  212. err = GetStatistics(
  213. dwLevel,
  214. INET_HTTP_SVC_ID,
  215. dwInstance,
  216. &buffer
  217. );
  218. if ( err == NO_ERROR ) {
  219. InfoStruct->StatInfo1 = (LPW3_STATISTICS_1)buffer;
  220. }
  221. return ( err);
  222. } // W3GetStatistics
  223. NET_API_STATUS
  224. NET_API_FUNCTION
  225. R_W3ClearStatistics2(
  226. IN LPWSTR pszServer OPTIONAL,
  227. IN DWORD dwInstance
  228. )
  229. /*++
  230. Description
  231. Clears the W3 specific statistics
  232. Arguments:
  233. pszServer - unused
  234. dwInstance - instance whose stats we should clear
  235. Note:
  236. --*/
  237. {
  238. DWORD err;
  239. err = ClearStatistics(
  240. INET_HTTP_SVC_ID,
  241. dwInstance
  242. );
  243. return err;
  244. } // W3ClearStatistics
  245. NET_API_STATUS
  246. NET_API_FUNCTION
  247. R_FtpQueryStatistics2(
  248. IN LPWSTR pszServer OPTIONAL,
  249. IN DWORD dwLevel,
  250. IN DWORD dwInstance,
  251. IN DWORD dwReserved,
  252. IN LPFTP_STATISTICS_STRUCT InfoStruct
  253. )
  254. /*++
  255. Description
  256. Gets the Ftp specific statistics
  257. Arguments:
  258. pszServer - unused
  259. dwLevel - level of the statistics to get
  260. dwInstance - instance whose stats we are to get
  261. dwReserved - MBZ
  262. InfoStruct - Will contain the returned buffer
  263. Note:
  264. --*/
  265. {
  266. DWORD err;
  267. PCHAR buffer;
  268. err = GetStatistics(
  269. dwLevel,
  270. INET_FTP_SVC_ID,
  271. dwInstance,
  272. &buffer
  273. );
  274. if ( err == NO_ERROR ) {
  275. InfoStruct->StatInfo0 = (LPFTP_STATISTICS_0)buffer;
  276. }
  277. return ( err);
  278. } // FtpGetStatistics
  279. NET_API_STATUS
  280. NET_API_FUNCTION
  281. R_FtpClearStatistics2(
  282. IN LPWSTR pszServer OPTIONAL,
  283. IN DWORD dwInstance
  284. )
  285. /*++
  286. Description
  287. Clears the Ftp specific statistics
  288. Arguments:
  289. pszServer - unused
  290. dwInstance - instance whose stats we should clear
  291. Note:
  292. --*/
  293. {
  294. DWORD err;
  295. err = ClearStatistics(
  296. INET_FTP_SVC_ID,
  297. dwInstance
  298. );
  299. return err;
  300. } // FtpClearStatistics
  301. NET_API_STATUS
  302. NET_API_FUNCTION
  303. R_IISEnumerateUsers(
  304. IN LPWSTR pszServer OPTIONAL,
  305. IN DWORD dwServiceId,
  306. IN DWORD dwInstance,
  307. OUT LPIIS_USER_ENUM_STRUCT InfoStruct
  308. )
  309. /*++
  310. Description
  311. Enumerates the users for a given instance.
  312. Arguments:
  313. pszServer - unused
  314. dwServiceId - service ID
  315. dwInstance - instance ID
  316. InfoStruct - structure to get the information with.
  317. Note:
  318. --*/
  319. {
  320. DWORD err = NO_ERROR;
  321. PCHAR buffer = NULL;
  322. DWORD nRead = 0;
  323. DWORD dwLevel = InfoStruct->Level;
  324. PIIS_SERVICE pInetSvc;
  325. IF_DEBUG( DLL_RPC) {
  326. DBGPRINTF( ( DBG_CONTEXT,
  327. " Entering R_IISEnumerateUsers (L%d) for Service %x\n",
  328. dwLevel, dwServiceId));
  329. }
  330. //
  331. // We only support 1
  332. //
  333. if ( dwLevel != 1 ) {
  334. return(ERROR_INVALID_LEVEL);
  335. }
  336. if ( ( err = TsApiAccessCheck( TCP_ENUMERATE_USERS)) != NO_ERROR) {
  337. IF_DEBUG( DLL_RPC) {
  338. DBGPRINTF( ( DBG_CONTEXT,
  339. " TsApiAccessCheck() Failed. Error = %u\n", err));
  340. }
  341. return(err);
  342. }
  343. pInetSvc = IIS_SERVICE::FindFromServiceInfoList( dwServiceId );
  344. if ( pInetSvc == NULL ) {
  345. buffer = NULL;
  346. nRead = 0;
  347. return ERROR_SERVICE_NOT_ACTIVE;
  348. }
  349. //
  350. // Get the params
  351. //
  352. if ( !pInetSvc->EnumerateInstanceUsers(
  353. dwInstance,
  354. &nRead,
  355. &buffer) ) {
  356. DBG_ASSERT(buffer == NULL);
  357. DBG_ASSERT(nRead == 0);
  358. err = GetLastError();
  359. } else {
  360. InfoStruct->ConfigInfo.Level1->Buffer =
  361. (LPIIS_USER_INFO_1)buffer;
  362. InfoStruct->ConfigInfo.Level1->EntriesRead = nRead;
  363. }
  364. //
  365. // This was referenced in Find
  366. //
  367. pInetSvc->Dereference( );
  368. return err;
  369. } // R_IISEnumerateUsers
  370. NET_API_STATUS
  371. NET_API_FUNCTION
  372. R_IISDisconnectUser(
  373. IN LPWSTR pszServer OPTIONAL,
  374. IN DWORD dwServiceId,
  375. IN DWORD dwInstance,
  376. IN DWORD dwIdUser
  377. )
  378. /*++
  379. Description
  380. Enumerates the users for a given instance.
  381. Arguments:
  382. pszServer - unused
  383. dwServiceId - service ID
  384. dwInstance - instance ID
  385. InfoStruct - structure to get the information with.
  386. Note:
  387. --*/
  388. {
  389. DWORD err = NO_ERROR;
  390. PIIS_SERVICE pInetSvc;
  391. IF_DEBUG( DLL_RPC) {
  392. DBGPRINTF( ( DBG_CONTEXT,
  393. " Entering R_IISDisconnectUsers for Service %x\n",
  394. dwServiceId));
  395. }
  396. if ( ( err = TsApiAccessCheck( TCP_DISCONNECT_USER )) != NO_ERROR) {
  397. IF_DEBUG( DLL_RPC) {
  398. DBGPRINTF( ( DBG_CONTEXT,
  399. " TsApiAccessCheck() Failed. Error = %u\n", err));
  400. }
  401. return(err);
  402. }
  403. pInetSvc = IIS_SERVICE::FindFromServiceInfoList( dwServiceId );
  404. if ( pInetSvc == NULL ) {
  405. return ERROR_SERVICE_NOT_ACTIVE;
  406. }
  407. //
  408. // Get the params
  409. //
  410. if ( !pInetSvc->DisconnectInstanceUser(
  411. dwInstance,
  412. dwIdUser) ) {
  413. err = GetLastError();
  414. }
  415. //
  416. // This was referenced in Find
  417. //
  418. pInetSvc->Dereference( );
  419. return ( err);
  420. } // R_IISDisconnectUsers