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.

848 lines
15 KiB

  1. /*++
  2. Copyright (c) 1991-1995 Microsoft Corporation
  3. Module Name:
  4. SmtpStub.C
  5. Abstract:
  6. These are the smtp service API RPC client stubs.
  7. Author:
  8. Johnson Apacible (johnsona) 17-Oct-1995
  9. template used srvstub.c (Dan Lafferty)
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. //
  15. // INCLUDES
  16. //
  17. #include <windows.h>
  18. #include <apiutil.h>
  19. #include <lmcons.h> // NET_API_STATUS
  20. #include <inetinfo.h>
  21. #include <smtpapi.h>
  22. #include <smtpsvc.h>
  23. NET_API_STATUS
  24. NET_API_FUNCTION
  25. SmtpQueryStatistics(
  26. IN LPWSTR servername,
  27. IN DWORD level,
  28. OUT LPBYTE *bufptr
  29. )
  30. /*++
  31. Routine Description:
  32. This is the DLL entrypoint for SmtpGetStatistics
  33. Arguments:
  34. servername --A pointer to an ASCIIZ string containing the name of
  35. the remote server on which the function is to execute. A NULL
  36. pointer or string specifies the local machine.
  37. level --Level of information required. 100, 101 and 102 are valid
  38. for all platforms. 302, 402, 403, 502 are valid for the
  39. appropriate platform.
  40. bufptr --On return a pointer to the return information structure
  41. is returned in the address pointed to by bufptr.
  42. Return Value:
  43. --*/
  44. {
  45. NET_API_STATUS apiStatus;
  46. *bufptr = NULL; // Must be NULL so RPC knows to fill it in.
  47. RpcTryExcept
  48. apiStatus = SmtprQueryStatistics(
  49. servername,
  50. level,
  51. (LPSTAT_INFO) bufptr);
  52. RpcExcept( EXCEPTION_EXECUTE_HANDLER )
  53. apiStatus = RpcExceptionCode( );
  54. RpcEndExcept
  55. return(apiStatus);
  56. } // SmtpQueryStatistics
  57. NET_API_STATUS
  58. NET_API_FUNCTION
  59. SmtpClearStatistics(
  60. IN LPWSTR Server OPTIONAL, IN DWORD dwInstance)
  61. {
  62. NET_API_STATUS status;
  63. RpcTryExcept {
  64. //
  65. // Try RPC (local or remote) version of API.
  66. //
  67. status = SmtpClearStatistics(
  68. Server, dwInstance
  69. );
  70. }
  71. RpcExcept (1) {
  72. status = RpcExceptionCode();
  73. }
  74. RpcEndExcept
  75. return (status);
  76. } // SmtpClearStatistics
  77. NET_API_STATUS
  78. NET_API_FUNCTION
  79. SmtpGetAdminInformation(
  80. IN LPWSTR pszServer OPTIONAL,
  81. OUT LPSMTP_CONFIG_INFO * ppConfig,
  82. IN DWORD dwInstance
  83. )
  84. /*++
  85. Routine Description:
  86. This is the DLL entrypoint for SmtpGetAdminInformation
  87. Arguments:
  88. servername --A pointer to an ASCIIZ string containing the name of
  89. the remote server on which the function is to execute. A NULL
  90. pointer or string specifies the local machine.
  91. ppConfig --Configuration information returned from the server.
  92. Return Value:
  93. --*/
  94. {
  95. NET_API_STATUS apiStatus;
  96. *ppConfig = NULL; // Must be NULL so RPC knows to fill it in.
  97. RpcTryExcept
  98. apiStatus = SmtprGetAdminInformation(
  99. pszServer,
  100. (LPSMTP_CONFIG_INFO *) ppConfig,
  101. dwInstance);
  102. RpcExcept( EXCEPTION_EXECUTE_HANDLER )
  103. apiStatus = RpcExceptionCode( );
  104. RpcEndExcept
  105. return(apiStatus);
  106. } // SmtpGetAdminInformation
  107. NET_API_STATUS
  108. NET_API_FUNCTION
  109. SmtpSetAdminInformation(
  110. IN LPWSTR pszServer OPTIONAL,
  111. IN LPSMTP_CONFIG_INFO pConfig,
  112. IN DWORD dwInstance
  113. )
  114. /*++
  115. Routine Description:
  116. This is the DLL entrypoint for SmtpSetAdminInformation
  117. Arguments:
  118. servername --A pointer to an ASCIIZ string containing the name of
  119. the remote server on which the function is to execute. A NULL
  120. pointer or string specifies the local machine.
  121. pConfig --Configuration information to be set on the server.
  122. Return Value:
  123. --*/
  124. {
  125. NET_API_STATUS apiStatus;
  126. RpcTryExcept
  127. apiStatus = SmtprSetAdminInformation(
  128. pszServer,
  129. (LPSMTP_CONFIG_INFO) pConfig,
  130. dwInstance);
  131. RpcExcept( EXCEPTION_EXECUTE_HANDLER )
  132. apiStatus = RpcExceptionCode( );
  133. RpcEndExcept
  134. return(apiStatus);
  135. } // SmtpSetAdminInformation
  136. /*++
  137. Routine Description:
  138. SmtpGetConnectedUserList
  139. Return Value:
  140. API Status - NO_ERROR on success, WIN32 error code on failure.
  141. --*/
  142. NET_API_STATUS
  143. NET_API_FUNCTION
  144. SmtpGetConnectedUserList(
  145. IN LPWSTR wszServerName,
  146. OUT LPSMTP_CONN_USER_LIST *ppConnUserList,
  147. IN DWORD dwInstance
  148. )
  149. {
  150. NET_API_STATUS apiStatus;
  151. *ppConnUserList = NULL;
  152. RpcTryExcept {
  153. //
  154. // Try RPC (local or remote) version of API.
  155. //
  156. apiStatus = SmtprGetConnectedUserList(
  157. wszServerName,
  158. ppConnUserList,
  159. dwInstance
  160. );
  161. }
  162. RpcExcept (1) {
  163. apiStatus = RpcExceptionCode();
  164. }
  165. RpcEndExcept
  166. return apiStatus;
  167. }
  168. /*++
  169. Routine Description:
  170. SmtpDisconnectUser
  171. Return Value:
  172. API Status - NO_ERROR on success, WIN32 error code on failure.
  173. --*/
  174. NET_API_STATUS
  175. NET_API_FUNCTION
  176. SmtpDisconnectUser(
  177. IN LPWSTR wszServerName,
  178. IN DWORD dwUserId,
  179. IN DWORD dwInstance
  180. )
  181. {
  182. NET_API_STATUS apiStatus;
  183. RpcTryExcept {
  184. //
  185. // Try RPC (local or remote) version of API.
  186. //
  187. apiStatus = SmtprDisconnectUser(
  188. wszServerName,
  189. dwUserId,
  190. dwInstance
  191. );
  192. }
  193. RpcExcept (1) {
  194. apiStatus = RpcExceptionCode();
  195. }
  196. RpcEndExcept
  197. return apiStatus;
  198. }
  199. /*++
  200. Routine Description:
  201. SmtpCreateUser
  202. Return Value:
  203. API Status - NO_ERROR on success, WIN32 error code on failure.
  204. --*/
  205. NET_API_STATUS
  206. NET_API_FUNCTION
  207. SmtpCreateUser(
  208. IN LPWSTR wszServerName,
  209. IN LPWSTR wszEmail,
  210. IN LPWSTR wszForwardEmail,
  211. IN DWORD dwLocal,
  212. IN DWORD dwMailboxSize,
  213. IN DWORD dwMailboxMessageSize,
  214. IN LPWSTR wszVRoot,
  215. IN DWORD dwInstance
  216. )
  217. {
  218. NET_API_STATUS apiStatus;
  219. RpcTryExcept {
  220. //
  221. // Try RPC (local or remote) version of API.
  222. //
  223. apiStatus = SmtprCreateUser(
  224. wszServerName,
  225. wszEmail,
  226. wszForwardEmail,
  227. dwLocal,
  228. dwMailboxSize,
  229. dwMailboxMessageSize,
  230. wszVRoot,
  231. dwInstance
  232. );
  233. }
  234. RpcExcept (1) {
  235. apiStatus = RpcExceptionCode();
  236. }
  237. RpcEndExcept
  238. return apiStatus;
  239. }
  240. /*++
  241. Routine Description:
  242. SmtpDeleteUser
  243. Return Value:
  244. API Status - NO_ERROR on success, WIN32 error code on failure.
  245. --*/
  246. NET_API_STATUS
  247. NET_API_FUNCTION
  248. SmtpDeleteUser(
  249. IN LPWSTR wszServerName,
  250. IN LPWSTR wszEmail,
  251. IN DWORD dwInstance
  252. )
  253. {
  254. NET_API_STATUS apiStatus;
  255. RpcTryExcept {
  256. //
  257. // Try RPC (local or remote) version of API.
  258. //
  259. apiStatus = SmtprDeleteUser(
  260. wszServerName,
  261. wszEmail,
  262. dwInstance
  263. );
  264. }
  265. RpcExcept (1) {
  266. apiStatus = RpcExceptionCode();
  267. }
  268. RpcEndExcept
  269. return apiStatus;
  270. }
  271. /*++
  272. Routine Description:
  273. SmtpGetUserProps
  274. Return Value:
  275. API Status - NO_ERROR on success, WIN32 error code on failure.
  276. --*/
  277. NET_API_STATUS
  278. NET_API_FUNCTION
  279. SmtpGetUserProps(
  280. IN LPWSTR wszServerName,
  281. IN LPWSTR wszEmail,
  282. OUT LPSMTP_USER_PROPS *ppUserProps,
  283. IN DWORD dwInstance
  284. )
  285. {
  286. NET_API_STATUS apiStatus;
  287. *ppUserProps = NULL;
  288. RpcTryExcept {
  289. //
  290. // Try RPC (local or remote) version of API.
  291. //
  292. apiStatus = SmtprGetUserProps(
  293. wszServerName,
  294. wszEmail,
  295. ppUserProps,
  296. dwInstance
  297. );
  298. }
  299. RpcExcept (1) {
  300. apiStatus = RpcExceptionCode();
  301. }
  302. RpcEndExcept
  303. return apiStatus;
  304. }
  305. /*++
  306. Routine Description:
  307. SmtpSetUserProps
  308. Return Value:
  309. API Status - NO_ERROR on success, WIN32 error code on failure.
  310. --*/
  311. NET_API_STATUS
  312. NET_API_FUNCTION
  313. SmtpSetUserProps(
  314. IN LPWSTR wszServerName,
  315. IN LPWSTR wszEmail,
  316. IN LPSMTP_USER_PROPS pUserProps,
  317. IN DWORD dwInstance
  318. )
  319. {
  320. NET_API_STATUS apiStatus;
  321. RpcTryExcept {
  322. //
  323. // Try RPC (local or remote) version of API.
  324. //
  325. apiStatus = SmtprSetUserProps(
  326. wszServerName,
  327. wszEmail,
  328. pUserProps,
  329. dwInstance
  330. );
  331. }
  332. RpcExcept (1) {
  333. apiStatus = RpcExceptionCode();
  334. }
  335. RpcEndExcept
  336. return apiStatus;
  337. }
  338. /*++
  339. Routine Description:
  340. SmtpCreateDistList
  341. Return Value:
  342. API Status - NO_ERROR on success, WIN32 error code on failure.
  343. --*/
  344. NET_API_STATUS
  345. NET_API_FUNCTION
  346. SmtpCreateDistList(
  347. IN LPWSTR wszServerName,
  348. IN LPWSTR wszEmail,
  349. IN DWORD dwType,
  350. IN DWORD dwInstance
  351. )
  352. {
  353. NET_API_STATUS apiStatus;
  354. RpcTryExcept {
  355. //
  356. // Try RPC (local or remote) version of API.
  357. //
  358. apiStatus = SmtprCreateDistList(
  359. wszServerName,
  360. wszEmail,
  361. dwType,
  362. dwInstance
  363. );
  364. }
  365. RpcExcept (1) {
  366. apiStatus = RpcExceptionCode();
  367. }
  368. RpcEndExcept
  369. return apiStatus;
  370. }
  371. /*++
  372. Routine Description:
  373. SmtpDeleteDistList
  374. Return Value:
  375. API Status - NO_ERROR on success, WIN32 error code on failure.
  376. --*/
  377. NET_API_STATUS
  378. NET_API_FUNCTION
  379. SmtpDeleteDistList(
  380. IN LPWSTR wszServerName,
  381. IN LPWSTR wszEmail,
  382. IN DWORD dwInstance
  383. )
  384. {
  385. NET_API_STATUS apiStatus;
  386. RpcTryExcept {
  387. //
  388. // Try RPC (local or remote) version of API.
  389. //
  390. apiStatus = SmtprDeleteDistList(
  391. wszServerName,
  392. wszEmail,
  393. dwInstance
  394. );
  395. }
  396. RpcExcept (1) {
  397. apiStatus = RpcExceptionCode();
  398. }
  399. RpcEndExcept
  400. return apiStatus;
  401. }
  402. /*++
  403. Routine Description:
  404. SmtpCreateDistListMember
  405. Return Value:
  406. API Status - NO_ERROR on success, WIN32 error code on failure.
  407. --*/
  408. NET_API_STATUS
  409. NET_API_FUNCTION
  410. SmtpCreateDistListMember(
  411. IN LPWSTR wszServerName,
  412. IN LPWSTR wszEmail,
  413. IN LPWSTR wszEmailMember,
  414. IN DWORD dwInstance
  415. )
  416. {
  417. NET_API_STATUS apiStatus;
  418. RpcTryExcept {
  419. //
  420. // Try RPC (local or remote) version of API.
  421. //
  422. apiStatus = SmtprCreateDistListMember(
  423. wszServerName,
  424. wszEmail,
  425. wszEmailMember,
  426. dwInstance
  427. );
  428. }
  429. RpcExcept (1) {
  430. apiStatus = RpcExceptionCode();
  431. }
  432. RpcEndExcept
  433. return apiStatus;
  434. }
  435. /*++
  436. Routine Description:
  437. SmtpDeleteDistListMember
  438. Return Value:
  439. API Status - NO_ERROR on success, WIN32 error code on failure.
  440. --*/
  441. NET_API_STATUS
  442. NET_API_FUNCTION
  443. SmtpDeleteDistListMember(
  444. IN LPWSTR wszServerName,
  445. IN LPWSTR wszEmail,
  446. IN LPWSTR wszEmailMember,
  447. IN DWORD dwInstance
  448. )
  449. {
  450. NET_API_STATUS apiStatus;
  451. RpcTryExcept {
  452. //
  453. // Try RPC (local or remote) version of API.
  454. //
  455. apiStatus = SmtprDeleteDistListMember(
  456. wszServerName,
  457. wszEmail,
  458. wszEmailMember,
  459. dwInstance
  460. );
  461. }
  462. RpcExcept (1) {
  463. apiStatus = RpcExceptionCode();
  464. }
  465. RpcEndExcept
  466. return apiStatus;
  467. }
  468. /*++
  469. Routine Description:
  470. SmtpGetNameList
  471. Return Value:
  472. API Status - NO_ERROR on success, WIN32 error code on failure.
  473. --*/
  474. NET_API_STATUS
  475. NET_API_FUNCTION
  476. SmtpGetNameList(
  477. IN LPWSTR wszServerName,
  478. IN LPWSTR wszEmail,
  479. IN DWORD dwType,
  480. IN DWORD dwRowsRequested,
  481. IN BOOL fForward,
  482. OUT LPSMTP_NAME_LIST *ppNameList,
  483. IN DWORD dwInstance
  484. )
  485. {
  486. NET_API_STATUS apiStatus;
  487. // Make sure RPC knows we want them to fill it in
  488. *ppNameList = NULL;
  489. RpcTryExcept {
  490. //
  491. // Try RPC (local or remote) version of API.
  492. //
  493. apiStatus = SmtprGetNameList(
  494. wszServerName,
  495. wszEmail,
  496. dwType,
  497. dwRowsRequested,
  498. fForward,
  499. ppNameList,
  500. dwInstance
  501. );
  502. }
  503. RpcExcept (1) {
  504. apiStatus = RpcExceptionCode();
  505. }
  506. RpcEndExcept
  507. return apiStatus;
  508. }
  509. /*++
  510. Routine Description:
  511. SmtpGetNameListFromList
  512. Return Value:
  513. API Status - NO_ERROR on success, WIN32 error code on failure.
  514. --*/
  515. NET_API_STATUS
  516. NET_API_FUNCTION
  517. SmtpGetNameListFromList(
  518. IN LPWSTR wszServerName,
  519. IN LPWSTR wszEmailList,
  520. IN LPWSTR wszEmail,
  521. IN DWORD dwType,
  522. IN DWORD dwRowsRequested,
  523. IN BOOL fForward,
  524. OUT LPSMTP_NAME_LIST *ppNameList,
  525. IN DWORD dwInstance
  526. )
  527. {
  528. NET_API_STATUS apiStatus;
  529. RpcTryExcept {
  530. //
  531. // Try RPC (local or remote) version of API.
  532. //
  533. apiStatus = SmtprGetNameListFromList(
  534. wszServerName,
  535. wszEmailList,
  536. wszEmail,
  537. dwType,
  538. dwRowsRequested,
  539. fForward,
  540. ppNameList,
  541. dwInstance
  542. );
  543. }
  544. RpcExcept (1) {
  545. apiStatus = RpcExceptionCode();
  546. }
  547. RpcEndExcept
  548. return apiStatus;
  549. }
  550. /*++
  551. Routine Description:
  552. SmtpGetVRootSize
  553. Return Value:
  554. API Status - NO_ERROR on success, WIN32 error code on failure.
  555. --*/
  556. NET_API_STATUS
  557. NET_API_FUNCTION
  558. SmtpGetVRootSize(
  559. IN LPWSTR wszServerName,
  560. IN LPWSTR wszVRoot,
  561. IN LPDWORD pdwBytes,
  562. IN DWORD dwInstance
  563. )
  564. {
  565. NET_API_STATUS apiStatus;
  566. RpcTryExcept {
  567. //
  568. // Try RPC (local or remote) version of API.
  569. //
  570. apiStatus = SmtprGetVRootSize(
  571. wszServerName,
  572. wszVRoot,
  573. pdwBytes,
  574. dwInstance
  575. );
  576. }
  577. RpcExcept (1) {
  578. apiStatus = RpcExceptionCode();
  579. }
  580. RpcEndExcept
  581. return apiStatus;
  582. }
  583. /*++
  584. Routine Description:
  585. SmtpBackupRoutingTable
  586. Return Value:
  587. API Status - NO_ERROR on success, WIN32 error code on failure.
  588. --*/
  589. NET_API_STATUS
  590. NET_API_FUNCTION
  591. SmtpBackupRoutingTable(
  592. IN LPWSTR wszServerName,
  593. IN LPWSTR wszPath,
  594. IN DWORD dwInstance
  595. )
  596. {
  597. NET_API_STATUS apiStatus;
  598. RpcTryExcept {
  599. //
  600. // Try RPC (local or remote) version of API.
  601. //
  602. apiStatus = SmtprBackupRoutingTable(
  603. wszServerName,
  604. wszPath,
  605. dwInstance
  606. );
  607. }
  608. RpcExcept (1) {
  609. apiStatus = RpcExceptionCode();
  610. }
  611. RpcEndExcept
  612. return apiStatus;
  613. }