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.

404 lines
8.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. rpcsupp.cxx
  7. This module contains support routines for the W3 Service RPC
  8. interface.
  9. FILE HISTORY:
  10. KeithMo 23-Mar-1993 Created.
  11. */
  12. #include "w3p.hxx"
  13. #include "w3svci_s.h"
  14. #include <timer.h>
  15. #include <time.h>
  16. //
  17. // Private globals.
  18. //
  19. //
  20. // Private prototypes.
  21. //
  22. BOOL
  23. WriteParams(
  24. W3_CONFIG_INFO * pConfig
  25. );
  26. //
  27. // Public functions.
  28. //
  29. NET_API_STATUS
  30. NET_API_FUNCTION
  31. W3rSetAdminInformation(
  32. IN LPWSTR pszServer OPTIONAL,
  33. IN W3_CONFIG_INFO * pConfig
  34. )
  35. {
  36. return ERROR_NOT_SUPPORTED;
  37. }
  38. NET_API_STATUS
  39. NET_API_FUNCTION
  40. W3rGetAdminInformation(
  41. IN LPWSTR pszServer OPTIONAL,
  42. OUT LPW3_CONFIG_INFO * ppConfig
  43. )
  44. {
  45. return ERROR_NOT_SUPPORTED;
  46. }
  47. /*******************************************************************
  48. NAME: W3rEnumerateUsers
  49. SYNOPSIS: Enumerates the connected users. This is a server-side
  50. worker routine for RPC.
  51. ENTRY: pszServer - Target server (unused).
  52. pBuffer - Will receive the number of entries and a
  53. pointer to the enumeration buffer.
  54. RETURNS: NET_API_STATUS - Net status code, NERR_Success if OK.
  55. HISTORY:
  56. KeithMo 23-Mar-1993 Created.
  57. ********************************************************************/
  58. NET_API_STATUS
  59. NET_API_FUNCTION
  60. W3rEnumerateUsers( W3_IMPERSONATE_HANDLE pszServer,
  61. LPW3_USER_ENUM_STRUCT pBuffer )
  62. {
  63. APIERR err;
  64. //DWORD cbBuffer;
  65. DBG_ASSERT( pBuffer != NULL );
  66. UNREFERENCED_PARAMETER(pszServer);
  67. IF_DEBUG( RPC )
  68. {
  69. DBGPRINTF(( DBG_CONTEXT,
  70. "in W3rEnumerateUsers\n" ));
  71. }
  72. //
  73. // Check for proper access.
  74. //
  75. err = TsApiAccessCheck( TCP_ENUMERATE_USERS );
  76. if( err != NO_ERROR )
  77. {
  78. IF_DEBUG( RPC )
  79. {
  80. DBGPRINTF(( DBG_CONTEXT,
  81. "W3rEnumerateUsers failed access check, error %lu\n",
  82. err ));
  83. }
  84. return (NET_API_STATUS)err;
  85. }
  86. #if 0
  87. //
  88. // Lock the user database.
  89. //
  90. LockUserDatabase();
  91. //
  92. // Determine the necessary buffer size.
  93. //
  94. pBuffer->EntriesRead = 0;
  95. pBuffer->Buffer = NULL;
  96. cbBuffer = 0;
  97. err = NERR_Success;
  98. EnumerateUsers( pBuffer, &cbBuffer );
  99. if( cbBuffer > 0 )
  100. {
  101. //
  102. // Allocate the buffer. Note that we *must*
  103. // use midl_user_allocate/midl_user_free.
  104. //
  105. pBuffer->Buffer = (W3_USER_INFO *) MIDL_user_allocate( (unsigned int)cbBuffer );
  106. if( pBuffer->Buffer == NULL )
  107. {
  108. err = ERROR_NOT_ENOUGH_MEMORY;
  109. }
  110. else
  111. {
  112. //
  113. // Since we've got the user database locked, there
  114. // *should* be enough room in the buffer for the
  115. // user data. If there isn't, we've messed up
  116. // somewhere.
  117. //
  118. TCP_REQUIRE( EnumerateUsers( pBuffer, &cbBuffer ) );
  119. }
  120. }
  121. //
  122. // Unlock the user database before returning.
  123. UnlockUserDatabase();
  124. #endif //0
  125. return (NET_API_STATUS)err;
  126. } // W3rEnumerateUsers
  127. /*******************************************************************
  128. NAME: W3rDisconnectUser
  129. SYNOPSIS: Disconnects a specified user. This is a server-side
  130. worker routine for RPC.
  131. ENTRY: pszServer - Target server (unused).
  132. idUser - Identifies the user to disconnect. If 0,
  133. then disconnect ALL users.
  134. RETURNS: NET_API_STATUS - Net status code, NERR_Success if OK.
  135. HISTORY:
  136. KeithMo 23-Mar-1993 Created.
  137. ********************************************************************/
  138. NET_API_STATUS
  139. NET_API_FUNCTION
  140. W3rDisconnectUser( W3_IMPERSONATE_HANDLE pszServer,
  141. DWORD idUser )
  142. {
  143. APIERR err = NERR_Success;
  144. UNREFERENCED_PARAMETER(pszServer);
  145. IF_DEBUG( RPC )
  146. {
  147. DBGPRINTF(( DBG_CONTEXT,
  148. "in W3rDisconnectUser\n" ));
  149. }
  150. //
  151. // Check for proper access.
  152. //
  153. err = TsApiAccessCheck( TCP_DISCONNECT_USER );
  154. if( err != NO_ERROR )
  155. {
  156. IF_DEBUG( RPC )
  157. {
  158. DBGPRINTF(( DBG_CONTEXT,
  159. "W3rDisconnectUser failed access check, error %lu\n",
  160. err ));
  161. }
  162. return (NET_API_STATUS)err;
  163. }
  164. //
  165. // Do it.
  166. //
  167. if( idUser == 0 )
  168. {
  169. CLIENT_CONN::DisconnectAllUsers();
  170. }
  171. else
  172. {
  173. #if 0
  174. if( !DisconnectUser( idUser ) )
  175. {
  176. err = NERR_UserNotFound;
  177. }
  178. #endif
  179. }
  180. return (NET_API_STATUS)err;
  181. } // W3rDisconnectUser
  182. /*******************************************************************
  183. NAME: W3rQueryStatistics
  184. SYNOPSIS: Queries the current server statistics. This is a
  185. server-side worker routine for RPC.
  186. ENTRY: pszServer - Target server (unused).
  187. Level - Info level. Currently only level 0 is
  188. supported.
  189. pBuffer - Will receive a poitner to the statistics
  190. structure.
  191. RETURNS: NET_API_STATUS - Net status code, NERR_Success if OK.
  192. HISTORY:
  193. KeithMo 02-Jun-1993 Created.
  194. ********************************************************************/
  195. NET_API_STATUS
  196. NET_API_FUNCTION
  197. W3rQueryStatistics( W3_IMPERSONATE_HANDLE pszServer,
  198. DWORD Level,
  199. LPSTATISTICS_INFO pBuffer )
  200. {
  201. APIERR err;
  202. TCP_ASSERT( pBuffer != NULL );
  203. UNREFERENCED_PARAMETER(pszServer);
  204. IF_DEBUG( RPC )
  205. {
  206. TCP_PRINT(( DBG_CONTEXT,
  207. "in W3rQueryStatistics, level %lu\n", Level ));
  208. }
  209. //
  210. // Check for proper access.
  211. //
  212. err = TsApiAccessCheck( TCP_QUERY_STATISTICS );
  213. if( err != NO_ERROR )
  214. {
  215. IF_DEBUG( RPC )
  216. {
  217. TCP_PRINT(( DBG_CONTEXT,
  218. "W3rQueryStatistics failed access check, error %lu\n",
  219. err ));
  220. }
  221. return (NET_API_STATUS)err;
  222. }
  223. #if 0
  224. //
  225. // Return the proper statistics based on the infolevel.
  226. //
  227. switch( Level )
  228. {
  229. case 0 :
  230. {
  231. LPW3_STATISTICS_0 pstats0;
  232. pstats0 = (W3_STATISTICS_0 *) MIDL_user_allocate( sizeof(W3_STATISTICS_0) );
  233. if( pstats0 == NULL )
  234. {
  235. err = ERROR_NOT_ENOUGH_MEMORY;
  236. }
  237. else
  238. {
  239. LockStatistics();
  240. RtlCopyMemory( pstats0, &W3Stats, sizeof(W3_STATISTICS_0) );
  241. UnlockStatistics();
  242. pBuffer->W3Stats0 = pstats0;
  243. pstats0->TimeOfLastClear = GetCurrentTimeInSeconds() -
  244. pstats0->TimeOfLastClear;
  245. }
  246. }
  247. break;
  248. default :
  249. err = ERROR_INVALID_LEVEL;
  250. break;
  251. }
  252. #else
  253. err = ERROR_NOT_SUPPORTED;
  254. #endif
  255. return (NET_API_STATUS)err;
  256. } // W3rQueryStatistics
  257. /*******************************************************************
  258. NAME: W3rClearStatistics
  259. SYNOPSIS: Clears current server statistics. This is a
  260. server-side worker routine for RPC.
  261. ENTRY: pszServer - Target server (unused).
  262. RETURNS: NET_API_STATUS - Net status code, NERR_Success if OK.
  263. HISTORY:
  264. KeithMo 02-Jun-1993 Created.
  265. ********************************************************************/
  266. NET_API_STATUS
  267. NET_API_FUNCTION
  268. W3rClearStatistics( W3_IMPERSONATE_HANDLE pszServer )
  269. {
  270. APIERR err;
  271. UNREFERENCED_PARAMETER(pszServer);
  272. IF_DEBUG( RPC )
  273. {
  274. TCP_PRINT(( DBG_CONTEXT,
  275. "in W3rClearStatistics\n" ));
  276. }
  277. //
  278. // Check for proper access.
  279. //
  280. err = TsApiAccessCheck( TCP_CLEAR_STATISTICS );
  281. if( err != NO_ERROR )
  282. {
  283. IF_DEBUG( RPC )
  284. {
  285. TCP_PRINT(( DBG_CONTEXT,
  286. "W3rClearStatistics failed access check, error %lu\n",
  287. err ));
  288. }
  289. return (NET_API_STATUS)err;
  290. }
  291. #if 0
  292. //
  293. // Clear the statistics.
  294. //
  295. ClearStatistics();
  296. #else
  297. err = ERROR_NOT_SUPPORTED;
  298. #endif
  299. return (NET_API_STATUS)err;
  300. } // W3rClearStatistics
  301.